土耳其和德国之间的日期时间转换 [英] conversion of datetime between turkey and germany
问题描述
嘿:)
我在将土耳其时间转换为德国时间时遇到问题:
I'm having problems converting turkish time to german time:
CultureInfo inf =新的System.Globalization.CultureInfo("tr-TR");
CultureInfo inf = new System.Globalization.CultureInfo( "tr-TR" );
字符串日期="08.11.2015 03:00";
string date = "08.11.2015 03:00";
字符串格式="dd.MM.yyyy HH:mm";
string format = "dd.MM.yyyy HH:mm";
DateTime dt;
DateTime dt;
如果(!DateTime.TryParseExact(日期,格式,inf,System.Globalization.DateTimeStyles.None,出dt))返回;
if (!DateTime.TryParseExact( date, format, inf, System.Globalization.DateTimeStyles.None, out dt )) return;
DateTime dtConv = TimeZoneInfo.ConvertTime(dt,mZoneFrom,mZoneTo);
DateTime dtConv = TimeZoneInfo.ConvertTime( dt, mZoneFrom, mZoneTo );
这里的问题是时间已转换为2:00,但我希望是1:00.
the problem here is that the time is converted to 2:00 but I expect 1:00.
时区对象mZoneFrom表示UTC + 3,mZoneTo表示UTC + 1.
the timezone object mZoneFrom says UTC+3, mZoneTo UTC+1.
我不明白为什么将凌晨3:00转换为凌晨2:00,而不是凌晨1:00.土耳其将时间从4:00调回3:00.
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?
我期待着您的来信.
最诚挚的问候
狂暴
推荐答案
似乎是由于2015年土耳其从夏令时转换而来的,因为 "mZoneFrom.IsAmbiguousTime(dt)" 为true.由于4:00变成3:00,因此很难说3:00(以及3:15等)是属于新的还是旧的3:00–4:00间隔,在此间隔内重复两次夜晚.系统假定已通过3:00 代表调整后的时间.
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.
这篇关于土耳其和德国之间的日期时间转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!