예제 #1
0
 def setUp(self):
     self._start_point = "19991226T0930Z"
     # Note: the following timezone will be Z-ified *after* truncation
     # or offsets are applied.
     self._end_point = "20010506T1200+0200"
     self._parsers = {
         0:
         CylcTimeParser(
             self._start_point, self._end_point,
             CylcTimeParser.initiate_parsers(
                 assumed_time_zone=UTC_UTC_OFFSET_HOURS_MINUTES)),
         2:
         CylcTimeParser(
             self._start_point, self._end_point,
             CylcTimeParser.initiate_parsers(
                 num_expanded_year_digits=2,
                 assumed_time_zone=UTC_UTC_OFFSET_HOURS_MINUTES))
     }
예제 #2
0
 def setUp(self):
     self._start_point = "19991226T0930Z"
     # Note: the following timezone will be Z-ified *after* truncation
     # or offsets are applied.
     self._end_point = "20010506T1200+0200"
     self._parsers = {
         0: CylcTimeParser(
             self._start_point, self._end_point,
             CylcTimeParser.initiate_parsers(
                 assumed_time_zone=UTC_UTC_OFFSET_HOURS_MINUTES
             )
         ),
         2: CylcTimeParser(
             self._start_point, self._end_point,
             CylcTimeParser.initiate_parsers(
                 num_expanded_year_digits=2,
                 assumed_time_zone=UTC_UTC_OFFSET_HOURS_MINUTES
             )
         )
     }
예제 #3
0
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
    )