问题描述
libical似乎只能接受奥尔森城市名称查找时区在其数据库中。
我已经得到了便携的是一个结构TM具有GMT偏移和速记3-4信code(EST / EDT等),但没有接受,在libical功能。
libical seems to only accept the Olsen city name to look up timezones in its database.What I've got that's portable is a struct tm which has a GMT offset and the shorthand 3-4 letter code (EST/EDT etc) but there's no function that accepts that in libical.
我有,我从libical试图匹配tznames扫描TZ列表一个真正糟糕的方式,而这可能会工作,但我深知这是一个坏主意。但我还没有找到让当地时区进入libical icaltimetype任何其他方式。
I have a really lousy way where I scan the tz list from libical trying to match the tznames, and that will probably work, but I am well aware this is a bad idea. But I haven't found any other way of getting the local timezone into a libical icaltimetype.
我失去了一些东西简单?
Am I missing something simple?
和便携式我的意思是窗户,OSX和Linux。
And by portable I mean windows, osx and linux.
这是一个C程序我写。
但我看到现在TZ偏移不是POSIX,这样就不会做的。
This is a c program I'm writing.But I see now that tz offset is not posix, so that won't do.
推荐答案
所以我认为,答案是没有答案。没有什么便携反正。
So I think the answer is that there is no answer. Nothing portable anyway.
所以,我对于linux和OSX单独的构建路径,我还没有得到到尚未窗口。
So I have separate build paths for linux and osx, and I haven't gotten to windows yet..
Linux实现只是读取从/ etc /时区(更多的是对的)
The linux implementation just reads from /etc/timezone (more on that on How do I find the current system timezone?)
和OSX实现这一点。
CFTimeZoneRef tzlocal = CFTimeZoneCopyDefault();
CFStringRef me = CFTimeZoneGetName(tzlocal);
NSString *local = (__bridge NSString *)me;
const char *tzname = [local cStringUsingEncoding:NSUTF8StringEncoding];
log.debug("Looking up timezone for %s", tzname);
// this is a built-in timezone so we don't have to free it.
local_timezone = icaltimezone_get_builtin_timezone(tzname);
不可移植,但至少它是正确的。
Not portable but at least it is correct.
这篇关于有没有一种可移植的方法来获得本地系统时区到libical icaltimetype?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!