Noda Time Instant to CET

I'm using the Noda Time libarary (v 2.0.3) for date time handling in a .net core project. However; I'm having some issues converting an instant to a CET date-time.

I'm fairly new to Noda Time, possibly using it wrong (is not CET tz-db entry referring to CET at all)?

Example code

// get current system instant
var systemInstant = SystemClock.Instance.GetCurrentInstant();

// get oslo zoneddatetime from instant
var osloDateTime = systemInstant.InZone(DateTimeZoneProviders.Tzdb["Europe/Oslo"]);
// get CET(?) zoneddatetime from instant
var cetDateTime = systemInstant.InZone(DateTimeZoneProviders.Tzdb["CET"]);

// output
Debug.WriteLine(osloDateTime.ToString());
Debug.WriteLine(cetDateTime.ToString());

The output from the example code above gives me:

2017-06-16T22:28:16 Europe/Oslo (+02)
2017-06-16T22:28:16 CET (+02)

Acutally I was expecting the CET zoned time to be 21:28:16 (UTC+1) and not 22:28:16 (UTC+2). UTC+1 is also what the Time and date website displaying.

Jon Skeet
people
quotationmark

The Zone line of the europe file in the IANA time zone database contains this single line for the CET zone ID:

Zone    CET     1:00    C-Eur   CE%sT

Then the end recurrence of the C-Eur rule is this pair of lines:

Rule    C-Eur   1981    max -   Mar lastSun  2:00s  1:00    S
Rule    C-Eur   1996    max -   Oct lastSun  2:00s  0   -

So it goes into UTC+2 at 2am on the last Sunday of March each year, and back to UTC+1 at 2am on the last Sunday of October each year.

Note that the "abbreviation" in the CET time zone will vary between "CET" and "CEST" - and that may be what's misleading you. But Noda Time is following the definition of the ID "CET" as per the IANA database.

This is just another reason to avoid using the abbreviations, and instead to use full zone IDs such as Europe/Oslo which are unambiguous. I would suggest avoid trying to use the concept of "a CET date-time" entirely.

people

See more on this question at Stackoverflow