Silverlight displays time zone info on mac and not PC using String(“G”) as format

China☆狼群 提交于 2020-01-06 07:08:57

问题


I've got a Silverlight application that shows some data. I use a DateTimeConverter to convert the DateTime value into a String. I use the dateTime.ToString("G") format and I get back 01/01/2010 12:01 or something like that. So far so good.

However, the same application on a Mac shows 01/01/2010 12:01 +02:00. That's the time CET with the current offset from UTC (so the time UTC is 10:01).

What is going on? Is there a special setting on the Mac? I played with the system settings and removed the CET and others from the text format but I still get the exact same result. Is this a bug?

EDIT: when I display the format pattern as suggested in the answer, I have HH:mm:ss on the PC and HH:mm:ss zzzz on the Mac. Cheers.


回答1:


That suggests the LongTimePattern is different on the Mac. (The "G" format specifier means "Short date and long time pattern".)

Try displaying CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern on both platforms and see what they say.




回答2:


Although on Windows changing the format in the control panel changes the format on a page refresh, this is NOT the case on MacOSX.

The setting used by the G format string is the Full format in System preferences -> Language & Text -> Times and not the Long format as I expected.

And once the settings are modified you HAVE to log off and log back in to see the changes.

The MSDN documentation should be a bit clearer on that methinks.

Thanks for the pointers Jon!

My only issue now is that I set the current culture for the user (so that the user can choose his language) and that unfortunately overrrides the user formatting if the language isn't the same as the one from his system. At least now I know what to tell the users.



来源:https://stackoverflow.com/questions/3297177/silverlight-displays-time-zone-info-on-mac-and-not-pc-using-stringg-as-forma

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!