为什么 OSX 上的区域设置没有改变?
我正在尝试在 Mac 上使用 strftime
以与区域设置相关的方式输出时间。
我正在设置区域设置并获取时间:
// sets the program's locale to the native locale
// without this line the locale is 'C'
log.debug(setlocale(LC_ALL,""));
struct tm* date = localtime(&time);
strftime(result.buf, size, "%X %x", date);
log.debug(result.buf);
哪个输出
en_GB.UTF-8
13:58:01 25/10/2011
是正确的。然而,我然后去了语言和课程。文本系统偏好设置面板,并将区域更改为美国。如果我再次运行程序,我会得到相同的区域设置,并且时间的格式也相同(我希望区域设置为 en_US
,日期格式为 10/25 /2011
)。我做错了什么?
I'm trying to use strftime
on a mac to output the time in a locale-dependent way.
I'm setting the locale and getting the time :
// sets the program's locale to the native locale
// without this line the locale is 'C'
log.debug(setlocale(LC_ALL,""));
struct tm* date = localtime(&time);
strftime(result.buf, size, "%X %x", date);
log.debug(result.buf);
which outputs
en_GB.UTF-8
13:58:01 25/10/2011
which is correct. However, I then go to the Language & Text System Preferences panel, and change the region to United States. If I run my program again, I get the same locale, and the time is formatted the same way (I'd expect the locale to be en_US
and the date to be formatted 10/25/2011
). What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要重新启动终端或启动程序的任何地方才能使更改生效。
You need to restart the terminal or whatever you're starting your program from for changes to take effect.