Questions tagged [boost-date-time]

Boost.Date_Time is a set of C++ date-time libraries based on generic programming concepts.

Boost.Date_Time is a set of C++ date-time libraries based on generic programming concepts.

Date-time libraries provide fundamental infrastructure for most development projects. However, most of them have limitations in their ability to calculate, format, convert, or perform some other functionality. For example, most libraries do not correctly handle leap seconds, provide concepts such as infinity, or provide the ability to use high resolution or network time sources. These libraries also tend to be rigid in their representation of dates and times. Thus customized policies for a project or subproject are not possible.

Programming with dates and times should be almost as simple and natural as programming with strings and integers. Applications with lots of temporal logic can be radically simplified by having a robust set of operators and calculation capabilities. Classes should provide the ability to compare dates and times, add lengths or time durations, retrieve dates and times from clocks, and work naturally with date and time intervals.

Another motivation for development of the library was to apply modern C++ library design techniques to the date-time domain. Really to build a framework for the construction of building temporal types. For example, by providing iterators and traits classes to control fundamental properties of the library. To the authors knowledge this library is the only substantial attempt to apply modern C++ to a date-time library.

127 questions
1
vote
2 answers

How do I convert time-uuid (stored in boost uuid) to a timestamp/time since epoch?

Converting from UUID timestamp to seconds since EPOCH seems quite easy based on the specs, also based on Cassandra's C++ driver source code based on its struct definition. However, when I try to do it, I always get the wrong value. I'm doing…
The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189
1
vote
2 answers

boost::date_time error while building MongoDB: winapi is not member

While building MongoDB with SCons and boost, I'm getting errors. Here's my command line: C:\mongo-cxx-driver>Scons --prefix=$HOME/mongo-client-lib --cpppath=C:\boost_1_66_0 --libpath=C:\boost_1_66_0\stage64\lib --dbg=on --64 install Here are the…
Antonio SEO
  • 457
  • 1
  • 9
  • 23
1
vote
1 answer

How do I instantiate a boost::date_time::time_duration with nanoseconds?

I feel like I'm missing something obvious here. I can easily make a time_duration with milliseconds, microseconds, or seconds by doing: time_duration t1 = seconds(1); time_duration t2 = milliseconds(1000); time_duration t3 =…
mpr
  • 3,250
  • 26
  • 44
1
vote
1 answer

How to get the current Boost time zone for Windows?

This is similar to How to get the current time zone? #include tzset(); time_zone_ptr zone(new posix_time_zone(tzname[localtime(0)->tm_isdst])); The above code throws 'bad cast' exception. The time zone from tzname or GetTimeZoneInformation…
user1633272
  • 2,007
  • 5
  • 25
  • 48
1
vote
1 answer

boost::locale::date_time: How to get data from date_time object in Boost C++?

I'm trying to handle dates and times in my code, and have been pointed in the direction of the boost library - specifically, boost::locale::date_time (in part because this lets me avoid Daylight Saving Time weirdness that was making my previous…
user3236291
  • 133
  • 7
1
vote
1 answer

boost::posix_time: retrieve time with daylight saving time

I'm using the following method for retrieving a string containing the current time using boost::posix_time: wstring TimeField::getActualTime() const { // Defined elsewhere auto m_facet = new new…
Jepessen
  • 11,744
  • 14
  • 82
  • 149
1
vote
1 answer

How date is stored internally by boost::gregorian::date?

Boost documentation says the following : "Internally boost::gregorian::date is stored as a 32 bit integer type." . I found this from the link : http://www.boost.org/doc/libs/1_56_0/doc/html/date_time/gregorian.html . How this 32 bit integer is…
Santanu C
  • 1,362
  • 3
  • 20
  • 38
1
vote
1 answer

boost::gregorian::date

I can't get it to work with visual c++ 2005 and boost 1.43 this simple source code : #include int main( int argc, char** argv ) { boost::gregorian::date d(); } gives a link-time error : error LNK2019: unresolved…
foke
  • 13
  • 2
1
vote
0 answers

Locale does not recognized for custom facet parsing Date / Time

I was looking for a sample to convert date to seconds from an arbitrary epoch (dates minor than the standard 1970) And I found the following very good sample (from an answer to): How to parse date/time from string? #define BOOST_ALL_NO_LIB #include…
1
vote
1 answer

boost date parse 29FEB

There is some problem with datetime parsing, that I have no idea about great workaround. Consider following code: #include #include #include namespace dt = boost::gregorian; dt::date…
ForEveR
  • 55,233
  • 2
  • 119
  • 133
1
vote
1 answer

boost date missing template arguments before

I'm getting a missing template arguments when compiling a simple date parsing test using boost, here is the code: #include "boost/date_time/gregorian/gregorian.hpp" #include "boost/date_time/gregorian/parsers.hpp" boost::date_time::date test =…
Johan Engblom
  • 215
  • 1
  • 12
1
vote
2 answers

boost::date_time with C++11 fails to compile

I recently upgraded my Intel C++ compiler from v13.0.1 (aka 2013) to v14.0.0 (aka 2013 sp1). It looks as though the standard libraries that it uses have become more C++11 compliant. As part of that, std::locale::facet was changed from: class…
RaveTheTadpole
  • 1,515
  • 13
  • 25
1
vote
1 answer

C++ arithmetic on time intervals

I already have working (ugly) code for this, but I will ask anyway: I have the time intervals [09:15, 10:00), [21:10, 21:45) during weekdays. Given time t and a number of seconds s, if t is within the intervals, I have to calculate the date and time…
nurettin
  • 11,090
  • 5
  • 65
  • 85
1
vote
1 answer

Boost date/time microsec_clock not compiling correctly

I'm trying to use the date/time facilities of the C++ Boost library v1.41. (Note: this is Linux, not Windows; g++ v4.4.7) Code: #include using boost::posix_time::ptime; using…
Chap
  • 3,649
  • 2
  • 46
  • 84
1
vote
2 answers

boost::gregorian::date from std::string

I tried to convert std::string into boost::gregorian::date in this way: #include #include "boost/date_time/gregorian/gregorian.hpp" int main(int argc, char *argv[]) { std::string s_date = "1922-02-29"; std::stringstream ss(s_date); …
Dejwi
  • 4,393
  • 12
  • 45
  • 74
1 2 3
8 9