如何解析字符串到的ctime结构? [英] How to parse a string to a ctime struct?

查看:154
本文介绍了如何解析字符串到的ctime结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有解析字符串到时间结构的建立方式?

Is there an established way to parse a string to a Time structure?

我想最好做的是的strftime(...),其中,而不是从时间结构和格式字符串产生一个字符串,我得到的反时间结构从根据所提供的格式字符串解析的串

What I would ideally like to do is the reverse of strftime(...), where instead of producing a string from a time struct and format string, I get a time struct from a string parsed according to the provided format string.

我preFER不通过包括DateTime类来添加额外的开销,如在升压找到或.NET

I would prefer not to add additional overhead by including a DateTime class such as that found in Boost or .NET

推荐答案

解析字符串结构TM相应的方法* 是的 strptime

The corresponding method for parsing strings to struct tm * is strptime.

不幸的是,这不是标准的C运行时库的一部分,例如上不存在窗户,但你可以重新使用BSD授权的版本,如<一个href=\"http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/25a654f9-b6b6-490a-8f36-c87483bb36b7\"相对=nofollow>这个。

Unfortunately this isn't part of the standard C runtime library and doesn't exist on e.g. windows, but you can reuse a BSD-licensed version, such as this one.

这篇关于如何解析字符串到的ctime结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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