Skip to content

Commit

Permalink
-- work in progress --
Browse files Browse the repository at this point in the history
  * removed code from setGMTOffset method and called base class method instead.
  * removed tzdata.js content.  It's a place holder file and I don't know about
    copyright issues should the tzdata content be stored in it.
  * readme formating fix.
  • Loading branch information
nzlosh committed Feb 13, 2013
1 parent aa99132 commit 387df02
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Installation
2 Extract the archive to your desired directory.
> mkdir /tmp/tzdata2012j
> tar xzvf tzdata2012j.tar.gz /tmp/tzdata2012j
3 Execute tz2js.py with tzdata's parent directory as an argument.
Expand Down
23 changes: 2 additions & 21 deletions tz2js.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,28 +326,9 @@ def getLocation(self):

def setGMTOffset(self, gmt_off):
"""
The gmt_off is expected in the form of "-1:33:40" and will be stored
internally as the number of seconds.
gmt_off is formatted as "-1:33:40" and is converted seconds.
"""
logging.debug("GMT offset convert to seconds %s" % gmt_off)

gmt_offset_time = 0 # The default value for the offset is 0:0:0 GMT
time_factor = [3600,60,1] # The factors to apply to each value h:m:s to calculate seconds.
signed = 1 # signed controls the factorisation of the time as positive or negitive

# Determine the number's sign
tmp = gmt_off.split("-",1)
if len(tmp) == 2: # A 2 subscript array means a negative digit.
signed = -1
gmt_off = tmp[1]

# Calculate time in seconds.
for x, v in enumerate(gmt_off.split(":")):
gmt_offset_time += int(v) * time_factor[x]

# Apply sign to conversion
self.gmt_off = gmt_offset_time * signed
logging.debug("\t == %s" % self.gmt_off)
self.gmt_off = self._TimeToSeconds(gmt_off)


def getGMTOffset(self):
Expand Down
1 change: 0 additions & 1 deletion tzdata.js
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
/dev/null

0 comments on commit 387df02

Please sign in to comment.