草庐IT

date_sub

全部标签

c++ - boost Date_Time 日期解析不起作用

我正在尝试使用boost1.55Date_Time库编写代码来解析日期时间字符串。但它总是产生非日期时间日期。boost::gregorian::dated(2005,6,25);boost::gregorian::dated2;boost::gregorian::date_facet*facet(newboost::gregorian::date_facet("%Y%m%d"));stringstreamss;ss.imbue(std::locale(std::cout.getloc(),facet));ss>d2;//not-a-date-timecout我尝试了不同的格式说明符,

c++ - GNU 使 : how to handle sub-projects

ProjFolder\Subfoldersources.cppmakefilemakefileSubfolder应该是一个单独的外部存储库,在checkout项目时拉入。当我将makeall调用到顶级makefile时,将执行以下配方:all:$(NAME).elf$(NAME).s19$(NAME).hex$(NAME).elf:$(OBJECTS)$(LDSCRIPT)Subfolder/lib.amake-CCppAudioPeriphsall@echo"...linking"$(CC)$(OBJECTS)Subfolder/lib.a$(LDFLAGS)$(LIBS)-o$@如

c++ - 现在我可以替换所有 Date 类吗?

我有一个很大的旧C++项目。它至少有三个日期和时间结构。它们看起来像:structDate{intday;intmonth;intyear;};structTime{inthour;intmin;intsecond;};其中一些使用double,用于Time::second,其中一些具有“优化”并使用short用于Time::(min,hour)和Date::(month,天).那么现在有了新的C++11标准(并且可能会得到boost)是否有可能用每个人都使用的东西代替它们?我看过std::chrono,但不知道如何使用它。例如,为了说明我这里想要的测试用例:我有一个函数,我为这个函数

c++ - 获取 boost::gregorian::date 的整数表示

来自关于boost::gregorian::date类的boost文档here:"Internallyboost::gregorian::dateisstoredasa32bitintegertype"现在这将是一个很好的、紧凑的方式,比如说,将这个日期存储在一个文件中。但是文档没有指定从对象中提取它的任何方法。问题是:有没有办法获得这个整数表示,以便稍后构造同一类的另一个相等的对象? 最佳答案 day_number()成员函数返回这个。boost::gregorian::dated(2014,10,18);uint32_tnumb

java~Date和LocalDateTime及Instant的使用场景

在Java中,LocalDateTime、Date和Instant分别代表了不同的日期时间类型,它们之间有一些区别和适用场景。Date:java.util.Date是Java早期的日期时间类,它包含了日期和时间信息,但是在设计上存在一些问题,因此并不推荐在新的代码中使用。Date类存在线程安全性问题,同时它的年份是从1900年开始计算,月份是从0开始计算,这种设计容易引起错误。在Java8之后,推荐使用新的日期时间API代替Date类。LocalDateTime:LocalDateTime是Java8引入的日期时间类,它表示了一个不带时区的日期时间,例如2024-02-21T14:30:00。

c++ - [over.sub]/1 中例子中使用的下标运算符是什么意思?

[over.sub]/1例子:structX{Zoperator[](std::initializer_list);};Xx;x[{1,2,3}]=7;//OK:meaningx.operator[]({1,2,3})inta[10];a[{1,2,3}]=7;//error:built-insubscriptoperatoroperator[]声明中的Z是什么?表达式x[{1,2,3}]=7;的可能含义是什么? 最佳答案 WhatisZintheoperator[]declaration?它是函数的返回类型。它根本没有在示例中使用

c++ - 如何根据 RFC 3339 格式化 boost::date_time-object

我想在boost中使用date_time库来表示我的应用程序中的时间。此应用程序将生成Atom提要,后者又会以RFC3339中指定的格式强制要求时间戳。,例如“1990-12-31T23:59:60Z”或“1990-12-31T15:59:60-08:00”。那么,我该如何根据这个RFC格式化时间呢?我一直在阅读DateTimeInput/Outputdocumentation一整天,我似乎无法找到如何在需要时将Z放在最后。此外,RFC支持可选的小数秒,但只有一位数字(例如“1990-12-31T23:59:60.5Z”)(*)。我似乎也不知道该怎么做。我总是可以编写自己的格式化例程来

c++ - 使用 Boost.Date_Time 解析带时区的日期时间?

我想使用BoostDateTimeIO解析带时区的日期时间图书馆。#include#include#includeusingnamespaceboost::gregorian;usingnamespaceboost::posix_time;std::chrono::system_clock::time_pointParseDate(conststd::wstring&dateText,constwchar_t*constformat){ptimetime;std::wstringstreambuffer(dateText);buffer.imbue(std::locale(std::l

date_add示例BigQuery返回错误

运行的示例BigQuery文档并在间隔中遇到错误。SELECTDATE_ADD(DATE"2008-12-25",INTERVAL5DAY)asfive_days_later;返回...Error:Encountered""\"2008-12-25\"""atline1,column22.Wasexpecting:")"...[TryusingstandardSQL(https://cloud.google.com/bigquery/docs/reference/standard-sql/enabling-standard-sql)]我在这里想念什么?检查了传统SQL。看答案此示例是针对Big

c++ - 为什么在使用命名空间 foo 时不能在 sub::bar 中使用 foo::bar 函数?

考虑以下程序:namespacefoo{namespacesub{intf();}//namespacesub}//namespacefoonamespacebar{namespacesub{intg(){usingnamespacefoo;returnsub::f()+1;}}//namespacesub}//namespacebar我希望它能编译,但它没有:$g++-6-ca.cppa.cpp:Infunction‘intbar::sub::g()’:a.cpp:12:9:error:‘f’isnotamemberof‘bar::sub’returnsub::f()+1;^~~a.