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
2
votes
1 answer

Compile error when including single boost posix_time.hpp header

I've run into a seemingly impenetrable compile error related to Boost, which I've reduced to including a single boost header file. In compiling (with GCC 4.2 on Mac OS X 10.6.8) an empty file containing only this include: #include…
SMGreenfield
  • 1,680
  • 19
  • 35
2
votes
2 answers

How do I force boost::posix_time to recognize timezones?

I'm reading timestamp fields from a PostgreSQL database. The timestamp column is defined as: my_timestamp TIMESTAMP WITH TIME ZONE DEFAULT NOW() When reading from the database, I convert it to a boost timestamp like this: boost::posix_time::ptime…
Stéphane
  • 19,459
  • 24
  • 95
  • 136
2
votes
1 answer

Convert Boost Ptime To EST UTC-5:00

I am using the following code to get the current date time (Mountain time) const boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); //In mountain time I get now = 2013-Apr-08 20:44:22 Now I am using the following…
MistyD
  • 16,373
  • 40
  • 138
  • 240
2
votes
1 answer

How can I use boost::thread::timed_join with nanoseconds enabled in boost::date_time?

Here is some C++ code illustrating my problem with a minimal expample: // uncomment the next line, to make it hang up: //#define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG //needed for nanosecond support of boost #include void foo() { …
Gösta
  • 21
  • 1
  • 7
2
votes
1 answer

How to create Boost ptime object from date input facet

I have tried to use the C++ Boost date_time library to load a string of the format “16:43 December 12, 2012” into a stringstream with a date input facet of “%H:%M %B %d, %Y”. Next I want to create a Boost ptime object from the stringstream so I can…
user1139053
  • 131
  • 3
  • 10
1
vote
1 answer

reading and writing dates with boost

I am trying to read/write dates in this format: yyyy-mm-ddThh:mm:ssZ I'm doing this : boost::posix_time::ptime t = boost::posix_time::time_from_string( "2012-02-20T00:26:39Z" ); std::cout << boost::posix_time::to_iso_extended_string( t ) <<…
foke
  • 1,339
  • 2
  • 12
  • 20
1
vote
1 answer

Is boost::posix_time::ptime safe to store in a Windows shared memory map?

I want to store a boost::posix_time::ptime object in a Windows shared memory map for multiple processes. However, for this to be safe, ptime cannot have pointers to other places in memory (i.e. it needs to be a POD) or else the various processes…
Elliot Cameron
  • 5,235
  • 2
  • 27
  • 34
1
vote
1 answer

Boost lib missing 'libboost_date_time-vc90-mt-gd-1_44.lib file. How to build only this lib file using bjam?

I need to use the date time functions available in booost/gregorian. When I compile in visual studio 2008 I get the error LINK : fatal error LNK1104: cannot open file 'libboost_date_time-vc90-mt-gd-1_44.lib'. I had a look at the lib folder in my…
Eternal Learner
  • 3,800
  • 13
  • 48
  • 78
1
vote
1 answer

Boost - Formatting sub second precision time with a time stamp

I need to get a nicely formatted timestamp (slightly modified ISO 8601) with millisecond precision. And example date would look like this: 2011-09-28 13:11:15.237-08:00 The formatting should be able to be overwridden as well. I've been playing…
Nicklas A.
  • 6,501
  • 7
  • 40
  • 65
1
vote
1 answer

How to convert nanoseconds to ptime in boost C++

Say I have a nanoseconds, 1614601874317571123. This represents the nanoseconds from epoch (1970-01-01). That is "2021-03-01T12:31:14.317571123" in ISO format I want to convert it to boost::posix_time::ptime. I know I could define a function…
Max Wong
  • 694
  • 10
  • 18
1
vote
1 answer

using to_iso_extended_string with boost date

I am trying to convert d2 to a string of the form '2011-08-02' so I can pass this to my sql statement. According to the boost site, to_iso_extended_string should return that format, but I get the following instead: '2011-Aug-02'. date…
itcplpl
  • 780
  • 4
  • 18
  • 29
1
vote
1 answer

converting boost::gregorian::date_duration to double

Is there a way to convert the boost::date_duration to a double. I have the following code: date be; date bd; days t = (be - bd); std::cout << "days are:" << t << std::endl; This works fine and returns the no. of days. But I want to get the value…
itcplpl
  • 780
  • 4
  • 18
  • 29
1
vote
1 answer

C++ - Calculate the millisecond from ptime in total seconds

How do i calculate the millisecond difference from the following Ptime ,I am using boost::ptime I'm trying to calculate the time_duration in milliseconds to find the difference. i get value like 999975 but expected value is 975 ptime PreviousgpsTime…
dinesh47
  • 37
  • 7
1
vote
2 answers

How to get a local date-time from a time_t with boost::date_time?

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. 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…
Klaim
  • 67,274
  • 36
  • 133
  • 188
1
vote
1 answer

Why std::bad_cast exception in boost::locale::date_time for global but not local objects?

I'm having problems writing a wrapper class using the boost::locale::date_time library. Specifically, I cannot create a global object from my class, though everything works fine other than that. Here's relevant sample code: //…
user3236291
  • 133
  • 7
1 2 3
8 9