none
conversion of datetime between turkey and germany RRS feed

  • Question

  • hey :)

    I'm having problems converting turkish time to german time:

    TimeZoneInfo mZoneFrom = TimeZoneInfo.FindSystemTimeZoneById( "Turkey Standard Time" );
    TimeZoneInfo mZoneTo = TimeZoneInfo.FindSystemTimeZoneById( "W. Europe Standard Time" );

    CultureInfo inf = new System.Globalization.CultureInfo( "tr-TR" );

    string date = "08.11.2015 03:00";

    string format = "dd.MM.yyyy HH:mm";

    DateTime dt;

    if (!DateTime.TryParseExact( date, format, inf, System.Globalization.DateTimeStyles.None, out dt )) return;

    DateTime dtConv = TimeZoneInfo.ConvertTime( dt, mZoneFrom, mZoneTo ); 

    the problem here is that the time is converted to 2:00 but I expect 1:00.

    the timezone object mZoneFrom says UTC+3, mZoneTo UTC+1. 

    I don't get it why 3:00 am is converted to 2:00 am instead of 1:00 am. turkey sets the clock back from 4:00 to 3:00.

    can someone explain this "phenomenon" to me? or can someone give me a hint how to use these objects correctly?

    I'm looking forward to hearing from you.

    best regards

    kraeppy


    • Edited by kraeppy Tuesday, January 10, 2017 2:23 PM typo
    Tuesday, January 10, 2017 2:18 PM

All replies

  • Seems that this is the result of switching from daylight saving time in Turkey in 2015, since ‘mZoneFrom.IsAmbiguousTime(dt)’ is true. Since 4:00 becomes 3:00, then it is difficult to say if 3:00 (as well as 3:15, etc.) belongs to new or old 3:00–4:00 interval, which is repeated twice during that night. The system assumes that the passed 3:00 represents the adjusted time.


    • Edited by Viorel_MVP Tuesday, January 10, 2017 6:31 PM
    • Proposed as answer by Kristin Xie Monday, January 16, 2017 8:45 AM
    Tuesday, January 10, 2017 6:30 PM