Question

Is there a list of breaking changes from .9 to 1.0 and 1.1?

The Version History starts at Version 1.0

For Example ... Original Code (on .9), now cries (on 1.1).

public static DateTime AdjustTo(this DateTime date, string timeZoneId)
{
    if (date == DateTime.MinValue)
        return date;
    DateTimeZone.SetProvider(new BclTimeZoneProvider());
    var zone = DateTimeZone.ForId(timeZoneId ?? "UTC");
    var dateTime = new ZonedDateTime(Instant.FromDateTimeUtc(date.ToUniversalTime()), zone);
    return dateTime.ToDateTimeUnspecified();
}

The above code has two breaking changes ... DateTimeZone doesn't have SetProvider or ForId methods.

Also, if I'm doign it wrong, I'll take that feedback as well.

Thank you.

Was it helpful?

Solution

To answer your first question: no, we only have version history from 1.0.0-beta1 onwards. Though as it turns out, we removed the concept of a static timezone provider in 1.0.0-beta2, so it is covered, albeit briefly:

  • Overhaul of how to get a DateTimeZone from an ID:
    • IDateTimeZoneProvider (SPI for time zones) renamed to IDateTimeZoneSource, along with similar renaming for the built-in sources
    • New interface IDateTimeZoneProvider aimed at callers, with caching assumed
    • New class DateTimeZoneProviders with static properties to access the built-in providers: TZDB, BCL and default (currently TZDB)
    • Removed various DateTimeZone static methods in favour of always going via an IDateTimeZoneProvider implementation
    • DateTimeZoneCache now public and implements IDateTimeZoneProvider

The equivalent to your code for 1.0 would be:

public static DateTime AdjustTo(this DateTime date, string timeZoneId)
{
    if (date == DateTime.MinValue)
        return date;
    var zone = DateTimeZoneProviders.Bcl[timeZoneId ?? "UTC"];
    var dateTime = new ZonedDateTime(Instant.FromDateTimeUtc(date.ToUniversalTime()), zone);
    return dateTime.ToDateTimeUnspecified();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top