simpleparse.common.timezone_names
index
/home/mcfletch/pylive/simpleparse/common/timezone_names.py

Common timezone names (civilian, military and combined)
 
These productions are a collection of common civilian and
military timezone names.  The list of names is by no means
exhaustive (nor definitive), but it gives most timezones
at least one named value (to make it possible to enter the
name), and it doesn't repeat any names (I hope ;) ).  You
have three major classes of names, civilian (EST, PST, GMT,
UTC), military single-character (A,B,C,D,E...) and military
phonetic spelling (Alpha, Bravo... Zulu).  The military
variants are combined into a single production, however.
 
        civilian_timezone_name -- the "familiar" timezones, most
                real-world data entry will want to use this as their
                "timezone" definition I'm guessing.
                
        military_timezone_name -- military timezones in the two
                formats outlined above.
                
        timezone_name -- combination of the two above into a
                single production.
 
Interpreter:
 
        TimeZoneNameInterpreter -- see below for details, by
                default takes the timezone name and converts to
                a second offset in West-negative format.  Note:
                this is the _opposite_ of the time module, but is
                the more commonly used format AFAIK.  Null matches
                will return a default TimeZone as specified.

 
Modules
       
simpleparse.common
simpleparse.objectgenerator
simpleparse.common.phonetics
time

 
Classes
       
TimeZoneNameInterpreter

 
class TimeZoneNameInterpreter
    Intepret a timezone specified as a military or civilian timezone name
 
Return value is an offset from UTC given in seconds.
If a null-match is passed uses the passed defaultZone.
Returns values in seconds difference from UTC (negative
West) divided by the passed "seconds" argument.
 
  Methods defined here:
__call__(self, (tag, left, right, children), buffer)
__init__(self, defaultZone=-14400, seconds=1.0)
defaultZone -- ofset in seconds to be returned if there
        is no value specified (null-match)
seconds -- divisor applied to the value before returning,
        if you want hours, use 3600.0, if you want minutes,
        use 60.0, if you want days (why?), use 86400.0

 
Functions
       
_build(data)
Build the name:time map and match rule for each dataset

 
Data
        LOCAL_ZONE = -14400
c = {'civilian_timezone_name': FirstOfGroup( children = [ Literal( ... value = 'ACSST', ), ], ), 'military_timezone_name': FirstOfGroup( children = [ Literal( ...ral( value = 'A', ), ], ), 'timezone_name': FirstOfGroup( children = [ Literal( ...ral( value = 'A', ), ], )}
civilian_data = [('NZDT', 46800), ('IDLE', 43200), ('NZST', 43200), ('NZT', 43200), ('AESST', 39600), ('ACSST', 37800), ('CADT', 37800), ('SADT', 37800), ('AEST', 36000), ('EAST', 36000), ('GST', 36000), ('LIGT', 36000), ('ACST', 34200), ('CAST', 34200), ('SAT', 34200), ('AWSST', 32400), ('JST', 32400), ('KST', 32400), ('WDT', 32400), ('MT', 30600), ...]
civilian_mapping = {'ACSST': 37800, 'ACST': 34200, 'ADT': -10800, 'AESST': 39600, 'AEST': 36000, 'AHST': -36000, 'AKST': -32400, 'AST': -14400, 'AT': -7200, 'AWSST': 32400, ...}
civilian_rule = FirstOfGroup( children = [ Literal( ... value = 'ACSST', ), ], )
item = 'Zulu'
key = 'Z'
timezone_data = [('NZDT', 46800), ('IDLE', 43200), ('NZST', 43200), ('NZT', 43200), ('AESST', 39600), ('ACSST', 37800), ('CADT', 37800), ('SADT', 37800), ('AEST', 36000), ('EAST', 36000), ('GST', 36000), ('LIGT', 36000), ('ACST', 34200), ('CAST', 34200), ('SAT', 34200), ('AWSST', 32400), ('JST', 32400), ('KST', 32400), ('WDT', 32400), ('MT', 30600), ...]
timezone_mapping = {'A': 3600, 'ACSST': 37800, 'ACST': 34200, 'ADT': -10800, 'AESST': 39600, 'AEST': 36000, 'AHST': -36000, 'AKST': -32400, 'AST': -14400, 'AT': -7200, ...}
timezone_rule = FirstOfGroup( children = [ Literal( ...ral( value = 'A', ), ], )
value = 0
zulu_data = [('Alpha', 3600), ('Bravo', 7200), ('Charlie', 10800), ('Delta', 14400), ('Echo', 18000), ('Echo', 18000), ('Foxtrot', 21600), ('Golf', 25200), ('Gulf', 25200), ('Hotel', 28800), ('India', 32400), ('Kilo', 36000), ('Lima', 39600), ('Mike', 43200), ('November', -3600), ('Oscar', -7200), ('Papa', -10800), ('Quebec', -14400), ('Romeo', -18000), ('Sierra', -21600), ...]
zulu_mapping = {'A': 3600, 'Alpha': 3600, 'B': 7200, 'Bravo': 7200, 'C': 10800, 'Charlie': 10800, 'D': 14400, 'Delta': 14400, 'E': 18000, 'Echo': 18000, ...}
zulu_rule = FirstOfGroup( children = [ Literal( ...ral( value = 'A', ), ], )