From f0e979fef30cdfa35c821bfc5f64051dd8eb1855 Mon Sep 17 00:00:00 2001 From: Eric Novotny Date: Tue, 3 Oct 2023 08:02:09 -0700 Subject: [PATCH] update version date --- src/cumulus_geoproc/utils/cgdal.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cumulus_geoproc/utils/cgdal.py b/src/cumulus_geoproc/utils/cgdal.py index 7cb651f..7c43565 100644 --- a/src/cumulus_geoproc/utils/cgdal.py +++ b/src/cumulus_geoproc/utils/cgdal.py @@ -398,7 +398,12 @@ def findsubset(ds: gdal.Dataset, subset_params): def getVersionDate( - ds: gdal.Dataset, src_path, metaVar: str, fileDateFormat: str, filedateSearch + ds: gdal.Dataset, + src_path, + metaVar: str, + fileDateFormat: str, + filedateSearch, + MetaDate=True, ): """Get the Version date of the grid Parameters @@ -412,6 +417,8 @@ def getVersionDate( format string for data in filename i.e. %Y%m%d_%H%M filedateSearch: regular expression operation regular expression operation to find date in filename + MetaDate: Boolean + Defaul = True. Use date from file metadata. If false it will only look at file. Returns ------- @@ -423,7 +430,7 @@ def getVersionDate( # get the version date_created = ds.GetMetadataItem(metaVar) date_created_match = re.search("\\d+", date_created) - if date_created_match: + if date_created_match and MetaDate: version_datetime = datetime.fromtimestamp(int(date_created_match[0])).replace( tzinfo=timezone.utc )