Skip to content

Commit

Permalink
Fixed timezone issues to ignore external TZ settings
Browse files Browse the repository at this point in the history
   - All Encoders use the UTC clock
   - timestamp in bulletinIdentifier is UTC based
  • Loading branch information
mgoberfield committed Jun 9, 2022
1 parent 6132f5c commit 616eb6d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions gifts/common/Encoder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os

from . import bulletin
from . import xmlConfig as des
Expand All @@ -11,6 +12,9 @@ def __init__(self):

self.geoLocationsDB = None
self._Logger = logging.getLogger(__name__)
#
# Always work in GMT
os.environ['TZ'] = 'GMT0'

def encode(self, text, receiptTime=None, **attrs):
"""Parses text to extract the WMO AHL line and one or more TAC forms.
Expand Down
4 changes: 2 additions & 2 deletions gifts/common/bulletin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
except ValueError:
pass

import datetime
import os
import re
import sys
import time
import uuid
import xml.etree.ElementTree as ET

Expand Down Expand Up @@ -117,7 +117,7 @@ def _export(self, compress=False):
metInfo = ET.SubElement(self.bulletin, 'meteorologicalInformation')
metInfo.append(child)

fn = '{}_{}.xml'.format(self._bulletinId, time.strftime('%Y%m%d%H%M%S'))
fn = '{}_{}.xml'.format(self._bulletinId, datetime.datetime.utcnow().strftime('%Y%m%d%H%M%S'))
if compress:
fn = '{}.gz'.format(fn)

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = IWXXM encoders for Annex3 TAC products
author = Mark Oberfield - NOAA/NWS/OSTI/MDL/WIAD
author_email = [email protected]
maintainer = Mark Oberfield
version = 1.4.0
version = 1.4.1
classifiers = Programming Language :: Python :: 3
Operating System :: OS Independent
Topic :: Text Processing :: Markup :: XML
Expand Down

0 comments on commit 616eb6d

Please sign in to comment.