datetime - Converting EST to IST gives error in C# -


i trying convert est( eastern standard time) ist (indian standard time) conversion showing incorrect results. can me on that?? searched on net , found using noda time can solve that. want solve using conventional datetime class.

here code , output:

datetime time= new datetime(1899,12,30, 23, 30 ,0); //some random date , 11:30 pm in est  timezoneinfo estzone = timezoneinfo.findsystemtimezonebyid("eastern standard time"); // eastern time zone  timezoneinfo istzone = timezoneinfo.findsystemtimezonebyid("india standard time"); // indian time zone  datetime localtime = timezoneinfo.converttime(time, estzone, istzone); // result 10:00 while should 09:00 am. 

a few things:

  • the timezoneinfo identifier "eastern standard time" refers north american eastern time zone, covering both eastern standard time , eastern daylight time. est utc-5, while edt utc-4. in general, should not infer names of these identifiers. see more examples in the timezone tag wiki.

  • the timezoneinfo.converttime method use whichever offset appropriate supplied date , time, correctly taking daylight saving time rules account.

  • the underlying time zone data windows not go 1899. there no sources of data guarantee historical dates time period. the iana time zone database used noda time makes educated guess. see history of dst in united states.

  • windows use earliest data has, zone uses daylight saving time rules in effect 1986 2007. these not current rules, make better sense use modern year, such datetime.today.year.

  • even if supplied modern year, correct converted time indeed 10:00 date in december. if want 9:00, try date in summer.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -