echyam commented on a change in pull request #10: SDAP-155 add processor to 
extract timestamp from granule metadata
URL: 
https://github.com/apache/incubator-sdap-ningesterpy/pull/10#discussion_r227165341
 
 

 ##########
 File path: sdap/processors/extracttimestampprocessor.py
 ##########
 @@ -0,0 +1,63 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import nexusproto
+from nexusproto.serialization import from_shaped_array
+
+import datetime
+import time
+import logging
+from netCDF4 import Dataset, num2date
+from pytz import timezone
+
+from sdap.processors import NexusTileProcessor
+
+EPOCH = timezone('UTC').localize(datetime.datetime(1970, 1, 1))
+
+
+def to_seconds_from_epoch(timestamp, pattern='%Y-%m-%dT%H:%M:%S'):
+    try:
+        seconds = int(time.mktime(time.strptime(timestamp[:19], pattern)))
 
 Review comment:
   For the other datasets, the timestamp is already provided as an integer, 
which the datetime library can parse and be offset by a start date.  But this 
one is in the form `YYYY-mm-ddTHH:MM:SS` and needs to be converted first.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to