CreateAdjustmentRule method

TimeZoneAdjustmentRule CreateAdjustmentRule(
  1. DateTime? startDate,
  2. DateTime? endDate
)
Creates a time zone adjustment rule. The start date of the adjustment rule (null = DateTime.MinValue). The exclusive end date of the adjustment rule (null = DateTime.MaxValue).

Implementation

TimeZoneAdjustmentRule CreateAdjustmentRule(
  DateTime? startDate,
  DateTime? endDate,
) {
  final standardOffset = Duration(
    milliseconds: -TransitionToStandard!.TargetPeriod!.Bias!.time,
  );

  if (transitions.length == 1) {
    return TimeZoneAdjustmentRule.Standard(
      startDate,
      endDate,
      standardOffset,
    );
  }

  return TimeZoneAdjustmentRule(
    startDate,
    endDate,
    standardOffset,
    Duration(milliseconds: GetDaylightDelta().time),
    TransitionToDaylight!.CreateTransitionTime(),
    TransitionToStandard!.CreateTransitionTime(),
  );
}