1. <small id='nxmzl'></small><noframes id='nxmzl'>

        <legend id='nxmzl'><style id='nxmzl'><dir id='nxmzl'><q id='nxmzl'></q></dir></style></legend>
          <bdo id='nxmzl'></bdo><ul id='nxmzl'></ul>

      1. <i id='nxmzl'><tr id='nxmzl'><dt id='nxmzl'><q id='nxmzl'><span id='nxmzl'><b id='nxmzl'><form id='nxmzl'><ins id='nxmzl'></ins><ul id='nxmzl'></ul><sub id='nxmzl'></sub></form><legend id='nxmzl'></legend><bdo id='nxmzl'><pre id='nxmzl'><center id='nxmzl'></center></pre></bdo></b><th id='nxmzl'></th></span></q></dt></tr></i><div id='nxmzl'><tfoot id='nxmzl'></tfoot><dl id='nxmzl'><fieldset id='nxmzl'></fieldset></dl></div>
        <tfoot id='nxmzl'></tfoot>

      2. 如何将 boost::posix_time::ptime 转换为 time_t?

        How do I convert boost::posix_time::ptime to time_t?(如何将 boost::posix_time::ptime 转换为 time_t?)

        <small id='wiFoJ'></small><noframes id='wiFoJ'>

        <legend id='wiFoJ'><style id='wiFoJ'><dir id='wiFoJ'><q id='wiFoJ'></q></dir></style></legend>

        <tfoot id='wiFoJ'></tfoot>
        1. <i id='wiFoJ'><tr id='wiFoJ'><dt id='wiFoJ'><q id='wiFoJ'><span id='wiFoJ'><b id='wiFoJ'><form id='wiFoJ'><ins id='wiFoJ'></ins><ul id='wiFoJ'></ul><sub id='wiFoJ'></sub></form><legend id='wiFoJ'></legend><bdo id='wiFoJ'><pre id='wiFoJ'><center id='wiFoJ'></center></pre></bdo></b><th id='wiFoJ'></th></span></q></dt></tr></i><div id='wiFoJ'><tfoot id='wiFoJ'></tfoot><dl id='wiFoJ'><fieldset id='wiFoJ'></fieldset></dl></div>

                • <bdo id='wiFoJ'></bdo><ul id='wiFoJ'></ul>

                    <tbody id='wiFoJ'></tbody>
                • 本文介绍了如何将 boost::posix_time::ptime 转换为 time_t?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  是否有一些标准"的方法,或者我能做的最好的方法是通过从 gregorian::date(1970,1,1) 中减去来直接计算它?

                  解决方案

                  time_t 是用于以秒为单位(通常是纪元时间)保持时间的类型.我猜你是在纪元时间之后,如果是这样的话,除了你已经进行的减法之外,我不知道有任何方法可以直接获得纪元时间.一旦你有了 time_duration(减法的结果),你就可以在持续时间上调用 total_seconds() 并将其存储在 time_t 中.>

                  顺便说一句.如果你在时代之后,你可以简单地使用 gettimeofday() 并为自己省去一些麻烦!

                  Is there some "standard" way or the best I can do is to compute it directly by subtracting from gregorian::date(1970,1,1)?

                  解决方案

                  time_t is the type used to hold time in seconds (typically epoch time). I'm guessing you are after epoch time, if so I'm not aware of any way in boost of actually getting epoch time directly, aside from the subtraction you have already. Once you have a time_duration (result of the subtraction), you can call total_seconds() on the duration and store that in time_t.

                  btw. if you are after epoch time, you could simple use gettimeofday() and save yourself some headache!

                  这篇关于如何将 boost::posix_time::ptime 转换为 time_t?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to limit the number of running instances in C++(C++中如何限制运行实例的数量)
                  Using boost::asio::async_read with stdin?(将 boost::asio::async_read 与 stdin 一起使用?)
                  How to find out what dependencies (i.e other Boost libraries) a particular Boost library requires?(如何找出特定 Boost 库需要哪些依赖项(即其他 Boost 库)?)
                  What#39;s the purpose of a leading quot;::quot; in a C++ method call(引导“::的目的是什么?在 C++ 方法调用中)
                  Boost Spirit x3: parse into structs(Boost Spirit x3:解析为结构体)
                  How boost auto-linking makes choice?(boost自动链接如何做出选择?)

                  <legend id='4ceLH'><style id='4ceLH'><dir id='4ceLH'><q id='4ceLH'></q></dir></style></legend>
                    <bdo id='4ceLH'></bdo><ul id='4ceLH'></ul>

                      <small id='4ceLH'></small><noframes id='4ceLH'>

                        <tbody id='4ceLH'></tbody>

                        • <i id='4ceLH'><tr id='4ceLH'><dt id='4ceLH'><q id='4ceLH'><span id='4ceLH'><b id='4ceLH'><form id='4ceLH'><ins id='4ceLH'></ins><ul id='4ceLH'></ul><sub id='4ceLH'></sub></form><legend id='4ceLH'></legend><bdo id='4ceLH'><pre id='4ceLH'><center id='4ceLH'></center></pre></bdo></b><th id='4ceLH'></th></span></q></dt></tr></i><div id='4ceLH'><tfoot id='4ceLH'></tfoot><dl id='4ceLH'><fieldset id='4ceLH'></fieldset></dl></div>

                            <tfoot id='4ceLH'></tfoot>