【问题标题】:Is there a way to get regional time format with Boost?有没有办法使用 Boost 获得区域时间格式?
【发布时间】:2018-10-31 23:14:21
【问题描述】:

正如我试图在标题中提出的那样,我说的是区域时间格式。我有一个可以显示时间/日期的应用程序,但来自美国用户的问题是,为什么我要这样显示时间:21:30 而不是这样:9:30PM。我将日期显示为 22.05.2018 而不是 05.22.2018 的日期也是如此。

所以我的问题是:有没有办法获得时区标志或位置,甚至是已经格式化的时间,以便我可以显示不同地区的不同时间/日期?

【问题讨论】:

    标签: c++ boost boost-date-time


    【解决方案1】:

    Boost Locale

    double now=time(0);
    cout << as::datetime << as::local_time << "Local time is: "<< now << endl;
    cout << as::gmt << "GMT Time is: "<< now <<endl;
    cout << as::time_zone("EST") << "Eastern Standard Time is: "<< now <<endl;
    

    从字符串中解析日期并添加时区

    【讨论】:

    • 你好@Victor Gubin,std::locale 是等价的吗?
    • boost locale 只是为 std::locale 功能实现正确的方面。
    猜你喜欢
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 2017-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多