有没有一种可移植的方法来获得本地系统时区到libical icaltimetype?

编程入门 行业动态 更新时间:2024-10-26 13:18:51
本文介绍了有没有一种可移植的方法来获得本地系统时区到libical icaltimetype?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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?

本文发布于:2023-08-07 19:50:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1321423.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法来   时区   系统   icaltimetype   libical

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!