def get_point_as_seconds(self): """Compute and store my cycle point as seconds since epoch.""" if self.point_as_seconds is None: iso_timepoint = point_parse(str(self.point)) self.point_as_seconds = int( iso_timepoint.get('seconds_since_unix_epoch')) if iso_timepoint.time_zone.unknown: utc_offset_hours, utc_offset_minutes = (get_local_time_zone()) utc_offset_in_seconds = (3600 * utc_offset_hours + 60 * utc_offset_minutes) self.point_as_seconds += utc_offset_in_seconds return self.point_as_seconds
def init(num_expanded_year_digits=0, custom_dump_format=None, time_zone=None, assume_utc=False, cycling_mode=None): """Initialise workflow-setup-specific information.""" if cycling_mode in Calendar.default().MODES: Calendar.default().set_mode(cycling_mode) if time_zone is None: if assume_utc: time_zone = "Z" time_zone_hours_minutes = (0, 0) else: time_zone = get_local_time_zone_format(TimeZoneFormatMode.reduced) time_zone_hours_minutes = get_local_time_zone() else: time_zone_hours_minutes = TimePointDumper().get_time_zone(time_zone) WorkflowSpecifics.ASSUMED_TIME_ZONE = time_zone_hours_minutes WorkflowSpecifics.NUM_EXPANDED_YEAR_DIGITS = num_expanded_year_digits if custom_dump_format is None: if num_expanded_year_digits > 0: WorkflowSpecifics.DUMP_FORMAT = ( EXPANDED_DATE_TIME_FORMAT + time_zone ) else: WorkflowSpecifics.DUMP_FORMAT = DATE_TIME_FORMAT + time_zone else: WorkflowSpecifics.DUMP_FORMAT = custom_dump_format if "+X" not in custom_dump_format and num_expanded_year_digits: raise IllegalValueError( 'cycle point format', ('cylc', 'cycle point format'), WorkflowSpecifics.DUMP_FORMAT ) WorkflowSpecifics.iso8601_parsers = CylcTimeParser.initiate_parsers( dump_format=WorkflowSpecifics.DUMP_FORMAT, num_expanded_year_digits=num_expanded_year_digits, assumed_time_zone=WorkflowSpecifics.ASSUMED_TIME_ZONE ) (WorkflowSpecifics.point_parser, WorkflowSpecifics.interval_parser, WorkflowSpecifics.recurrence_parser) = WorkflowSpecifics.iso8601_parsers WorkflowSpecifics.abbrev_util = CylcTimeParser( None, None, WorkflowSpecifics.iso8601_parsers )
RE_DATE_TIME_FORMAT_EXTENDED = ( r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:Z|[+-][\d:]+)?") TIME_FORMAT_BASIC = "%H%M%S" TIME_FORMAT_BASIC_SUB_SECOND = "%H%M%S.%f" TIME_FORMAT_EXTENDED = "%H:%M:%S" TIME_FORMAT_EXTENDED_SUB_SECOND = "%H:%M:%S.%f" TIME_ZONE_STRING_LOCAL_BASIC = get_local_time_zone_format( TimeZoneFormatMode.reduced) TIME_ZONE_STRING_LOCAL_EXTENDED = get_local_time_zone_format( TimeZoneFormatMode.extended) TIME_ZONE_STRING_UTC = "Z" TIME_ZONE_UTC_UTC_OFFSET = (0, 0) TIME_ZONE_LOCAL_UTC_OFFSET = get_local_time_zone() TIME_ZONE_LOCAL_UTC_OFFSET_HOURS = TIME_ZONE_LOCAL_UTC_OFFSET[0] TIME_ZONE_LOCAL_UTC_OFFSET_MINUTES = TIME_ZONE_LOCAL_UTC_OFFSET[1] TIME_ZONE_LOCAL_INFO = { "hours": TIME_ZONE_LOCAL_UTC_OFFSET[0], "minutes": TIME_ZONE_LOCAL_UTC_OFFSET[1], "string_basic": TIME_ZONE_STRING_LOCAL_BASIC, "string_extended": TIME_ZONE_STRING_LOCAL_EXTENDED } TIME_ZONE_UTC_INFO = { "hours": TIME_ZONE_UTC_UTC_OFFSET[0], "minutes": TIME_ZONE_UTC_UTC_OFFSET[1], "string_basic": TIME_ZONE_STRING_UTC, "string_extended": TIME_ZONE_STRING_UTC