Boolean isAmbiguous = false;
AdjustmentRule rule = GetAdjustmentRuleForAmbiguousOffsets(adjustedTime);
if (rule != null && rule.HasDaylightSaving) {
- DaylightTime daylightTime = GetDaylightTime(adjustedTime.Year, rule);
+ DaylightTimeStruct daylightTime = GetDaylightTime(adjustedTime.Year, rule);
isAmbiguous = GetIsAmbiguousTime(adjustedTime, rule, daylightTime);
}
Boolean isAmbiguous = false;
AdjustmentRule rule = GetAdjustmentRuleForAmbiguousOffsets(adjustedTime);
if (rule != null && rule.HasDaylightSaving) {
- DaylightTime daylightTime = GetDaylightTime(adjustedTime.Year, rule);
+ DaylightTimeStruct daylightTime = GetDaylightTime(adjustedTime.Year, rule);
isAmbiguous = GetIsAmbiguousTime(adjustedTime, rule, daylightTime);
}
AdjustmentRule rule = GetAdjustmentRuleForTime(adjustedTime);
if (rule != null && rule.HasDaylightSaving) {
- DaylightTime daylightTime = GetDaylightTime(adjustedTime.Year, rule);
+ DaylightTimeStruct daylightTime = GetDaylightTime(adjustedTime.Year, rule);
return GetIsAmbiguousTime(adjustedTime, rule, daylightTime);
}
return false;
//
AdjustmentRule rule = GetAdjustmentRuleForTime(adjustedTime);
if (rule != null && rule.HasDaylightSaving) {
- DaylightTime daylightTime = GetDaylightTime(adjustedTime.Year, rule);
+ DaylightTimeStruct daylightTime = GetDaylightTime(adjustedTime.Year, rule);
return GetIsDaylightSavings(adjustedTime, rule, daylightTime, flags);
}
else {
AdjustmentRule rule = GetAdjustmentRuleForTime(dateTime);
if (rule != null && rule.HasDaylightSaving) {
- DaylightTime daylightTime = GetDaylightTime(dateTime.Year, rule);
+ DaylightTimeStruct daylightTime = GetDaylightTime(dateTime.Year, rule);
isInvalid = GetIsInvalidTime(dateTime, rule, daylightTime);
}
else {
sourceOffset = sourceOffset + sourceRule.BaseUtcOffsetDelta;
if (sourceRule.HasDaylightSaving) {
Boolean sourceIsDaylightSavings = false;
- DaylightTime sourceDaylightTime = sourceTimeZone.GetDaylightTime(dateTime.Year, sourceRule);
+ DaylightTimeStruct sourceDaylightTime = sourceTimeZone.GetDaylightTime(dateTime.Year, sourceRule);
// 'dateTime' might be in an invalid time range since it is in an AdjustmentRule
// period that supports DST
//
// Helper function that returns a DaylightTime from a year and AdjustmentRule
//
- private DaylightTime GetDaylightTime(Int32 year, AdjustmentRule rule) {
+ private DaylightTimeStruct GetDaylightTime(Int32 year, AdjustmentRule rule) {
TimeSpan delta = rule.DaylightDelta;
DateTime startTime;
DateTime endTime;
startTime = TransitionTimeToDateTime(year, rule.DaylightTransitionStart);
endTime = TransitionTimeToDateTime(year, rule.DaylightTransitionEnd);
}
- return new DaylightTime(startTime, endTime, delta);
+ return new DaylightTimeStruct(startTime, endTime, delta);
}
//
// Helper function that checks if a given dateTime is in Daylight Saving Time (DST)
// This function assumes the dateTime and AdjustmentRule are both in the same time zone
//
- static private Boolean GetIsDaylightSavings(DateTime time, AdjustmentRule rule, DaylightTime daylightTime, TimeZoneInfoOptions flags) {
+ static private Boolean GetIsDaylightSavings(DateTime time, AdjustmentRule rule, DaylightTimeStruct daylightTime, TimeZoneInfoOptions flags) {
if (rule == null) {
return false;
}
// Get the daylight changes for the year of the specified time.
- DaylightTime daylightTime = zone.GetDaylightTime(Year, rule);
+ DaylightTimeStruct daylightTime = zone.GetDaylightTime(Year, rule);
// The start and end times represent the range of universal times that are in DST for that year.
// Within that there is an ambiguous hour, usually right at the end, but at the beginning in
if (rule.IsStartDateMarkerForBeginningOfYear() && daylightTime.Start.Year > DateTime.MinValue.Year) {
AdjustmentRule previousYearRule = zone.GetAdjustmentRuleForTime(new DateTime(daylightTime.Start.Year - 1, 12, 31));
if (previousYearRule != null && previousYearRule.IsEndDateMarkerForEndOfYear()) {
- DaylightTime previousDaylightTime = zone.GetDaylightTime(daylightTime.Start.Year - 1, previousYearRule);
+ DaylightTimeStruct previousDaylightTime = zone.GetDaylightTime(daylightTime.Start.Year - 1, previousYearRule);
startTime = previousDaylightTime.Start - utc - previousYearRule.BaseUtcOffsetDelta;
ignoreYearAdjustment = true;
} else {
if (nextYearRule.IsEndDateMarkerForEndOfYear()) {// next year end with daylight saving on too
endTime = new DateTime(daylightTime.End.Year + 1, 12, 31) - utc - nextYearRule.BaseUtcOffsetDelta - nextYearRule.DaylightDelta;
} else {
- DaylightTime nextdaylightTime = zone.GetDaylightTime(daylightTime.End.Year + 1, nextYearRule);
+ DaylightTimeStruct nextdaylightTime = zone.GetDaylightTime(daylightTime.End.Year + 1, nextYearRule);
endTime = nextdaylightTime.End - utc - nextYearRule.BaseUtcOffsetDelta - nextYearRule.DaylightDelta;
}
ignoreYearAdjustment = true;
// In this example, any DateTime values that fall into the [1AM - 1:59:59AM] range
// are ambiguous; as it is unclear if these times are in Daylight Saving Time.
//
- static private Boolean GetIsAmbiguousTime(DateTime time, AdjustmentRule rule, DaylightTime daylightTime) {
+ static private Boolean GetIsAmbiguousTime(DateTime time, AdjustmentRule rule, DaylightTimeStruct daylightTime) {
Boolean isAmbiguous = false;
if (rule == null || rule.DaylightDelta == TimeSpan.Zero) {
return isAmbiguous;
// A "time hole" is not limited to only occurring at the start of DST, and may occur at
// the end of DST as well.
//
- static private Boolean GetIsInvalidTime(DateTime time, AdjustmentRule rule, DaylightTime daylightTime) {
+ static private Boolean GetIsInvalidTime(DateTime time, AdjustmentRule rule, DaylightTimeStruct daylightTime) {
Boolean isInvalid = false;
if (rule == null || rule.DaylightDelta == TimeSpan.Zero) {
return isInvalid;
if (rule != null) {
baseOffset = baseOffset + rule.BaseUtcOffsetDelta;
if (rule.HasDaylightSaving) {
- DaylightTime daylightTime = zone.GetDaylightTime(time.Year, rule);
+ DaylightTimeStruct daylightTime = zone.GetDaylightTime(time.Year, rule);
Boolean isDaylightSavings = GetIsDaylightSavings(time, rule, daylightTime, flags);
baseOffset += (isDaylightSavings ? rule.DaylightDelta : TimeSpan.Zero /* FUTURE: rule.StandardDelta */);
}