如何从用的boost :: date_time的一个time_t的本地日期时间? [英] How to get a local date-time from a time_t with boost::date_time?

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

问题描述

我使用boost :: date_time的,我得到了一个time_t的,已经由库使用的时间()函数从C标准库生成了。

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_r ,如果可用)标准库。

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

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

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