Skip to content

Commit

Permalink
wallclock.py speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
benfitzpatrick committed Sep 12, 2016
1 parent cd8e2a8 commit ecc1d12
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/cylc/wallclock.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from calendar import timegm
from datetime import datetime, timedelta

from isodatetime.parsers import TimePointParser
from isodatetime.timezone import (
get_local_time_zone_format, get_local_time_zone)

Expand Down Expand Up @@ -63,7 +62,7 @@
"string_extended": TIME_ZONE_STRING_UTC
}

PARSER = TimePointParser()
PARSER = None


def now(override_use_utc=None):
Expand Down Expand Up @@ -226,6 +225,10 @@ def get_unix_time_from_time_string(datetime_string):
date_time_utc = datetime.strptime(
datetime_string, DATE_TIME_FORMAT_EXTENDED + "Z")
except ValueError:
global PARSER
if PARSER is None:
from isodatetime.parsers import TimePointParser
PARSER = TimePointParser()
time_zone_info = PARSER.get_info(datetime_string)[1]
time_zone_hour = int(time_zone_info["time_zone_hour"])
time_zone_minute = int(time_zone_info.get("time_zone_minute", 0))
Expand Down

0 comments on commit ecc1d12

Please sign in to comment.