如何从time_t与boost :: date_time获取本地日期时间? [英] How to get a local date-time from a time_t with boost::date_time?

查看:190
本文介绍了如何从time_t与boost :: date_time获取本地日期时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用boost :: date_time,我得到一个time_t,它是由库使用C标准库的time()函数生成的。

I'm using boost::date_time and I got a time_t, that have been generated by a library using the time() function from the C standard library.

我正在寻找一种方式得到一个当地时间从那个time_t。我正在阅读的文档,没有找到任何方法来做这个没有提供一个时区,我不知道,因为它依赖于机器的地区,我找不到任何办法从它得到一个。

I'm looking for a way get a local time from that time_t. I'm reading the documentation and can't find any way to do this without providing a time zone, that I don't know about because it's dependant on the machine's locale, and I can't find any way to get one from it.

我缺少什么?

推荐答案

我会忽略 boost :: date_time ,只需使用 localtime (或 localtime_r ,如果有)。

For this task, I'd ignore boost::date_time and just use localtime (or localtime_r, if available) from the standard library.

这篇关于如何从time_t与boost :: date_time获取本地日期时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆