如何获得ICU中的所有时区名称
how to get all timezone names in ICU
我使用boost::locale与ICU后端进行不同时区之间的时间转换。在创建boost::local::Calendar时,我可以传入一个像"America/New_York"这样的字符串来指定时区信息。
但是我如何获得所有有效时区名称的列表?
来自ICU文档,它提到用户可以使用timezone . getavailableids()方法遍历所有时区名称。但我甚至找不到一个方法叫getavailableid在timezone。h
您可以使用TimeZone.createEnumeration()
获取所有时区名称的列表。文档中确实说使用getAvailabeIDs
,但这种方法似乎已经不存在了。
我设法实现这样,使用ICU 4.4.2:
#include <iostream>
#include <unicode/timezone.h>
#include <unicode/unistr.h>
using namespace icu;
int main()
{
StringEnumeration *timeZoneIds = TimeZone::createEnumeration();
UErrorCode status = U_ZERO_ERROR;
const UnicodeString *zoneId = timeZoneIds->snext(status);
while (zoneId != NULL && status == U_ZERO_ERROR)
{
std::string zoneIdString;
zoneId->toUTF8String(zoneIdString);
std::cout << zoneIdString << std::endl;
zoneId = timeZoneIds->snext(status);
}
delete timeZoneIds;
return 0;
}
相关文章:
- 正在查找文档以获得PS4平台的C++中的设备信息
- 如何从C++中的依赖类型中获得它所依赖的类型
- 欧拉项目#8答案是大以获得有效答案
- 如何使用C/C++在MacOSX中获得键盘布局
- 函数何时会在c++中包含stack_Unwind_Resume调用
- 如何在不产生任何垃圾的情况下获得C中的像素
- 有没有一种方法可以在编译时获得作用域类名
- 如何在C++中获得"静态纯虚拟"功能?
- Python中的for循环与C++有何不同
- Log4cpp:以UTC/GMT时区打印日期
- 如何设置一个范围来提取我想要获得的信息
- 在多次运行中获得一致的callgrind输出
- 通过错误处理,在C++中可靠地获得用户十六进制输入
- 如何在Directwrite中获得给定字体的可用OpenType功能
- 在我的代码中,获得最大的Pair Wise产品C++和输出并不总是正确的
- 当用户在qtablewidget中输入单元格时,如何获得信号?C++
- 未获得字符串中的预期输出
- C :如何使用ICU通过给定的时区偏移来获得当前时间
- C/C 获得时区偏移信息的时间戳
- 如何获得ICU中的所有时区名称