Context
We have a C# program, that deals with time.
We have clients in France, so we convert times to and from France's timezone.
In our C# code : we use Central European Standard Time
as a time zone for France.
It describes a timezone, which follows DST changes :
- on the last sunday of march (3 AM), clocks swicth to summer time are moved forward 1h
- on the last sunday of october (3 AM), clocks switch to winter time and are moved backward 1h
Our situation
The thing is : France aligned with CEST in 1996 ;
before that date, France would switch from summer time to winter time on the last sunday of september.
Window's CEST
timezone describes (accurately) CEST, which happens to not be 100% equivalent to France's timezone for dates before october 1995.
When testing the IANA database (in Windows subsystem for linux), it turns out the Europe/Paris timezone accurately switches time at the end of september for dates < 1995.
Question
is there either :
- a representation of
Europe/Paris
timezone in Window's list of standard timezones ? - a way to use the IANA database (and Europe/Paris) from C# ?
Sample code we use to convert time to UTC :
using System;
using System.Globalization;
namespace TestingApp
{
class Program
{
static void Main(string[] args)
{
var tz = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time");
string[] times = {
// In 1995 :
// last sunday in september was sept. 24th
// last sunday in october was oct. 29th
"1995/09/23 12:00:00", "1995/09/24 12:00:00",
"1995/10/28 12:00:00", "1995/10/29 12:00:00",
};
foreach (var t in times) {
var utc = DateTime.ParseExact(t, "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None);
utc = TimeZoneInfo.ConvertTime(utc, tz, TimeZoneInfo.Utc);
Console.WriteLine(String.Format("Paris: {0} -> UTC: {1}", t, utc.ToString()));
}
}
}
}
// Output :
// Paris: 1995/09/23 12:00:00 -> UTC: 23/09/1995 10:00:00
// Paris: 1995/09/24 12:00:00 -> UTC: 24/09/1995 10:00:00 <- instead of 11:00:00 UTC
// Paris: 1995/10/28 12:00:00 -> UTC: 28/10/1995 10:00:00 <- instead of 11:00:00 UTC
// Paris: 1995/10/29 12:00:00 -> UTC: 29/10/1995 11:00:00