Opened 9 years ago

Closed 4 months ago

#2818 closed Bugs (fixed)

boost::posix_time::from_time_t() assumes boost::int32_t == long

Reported by: pelee@… Owned by: James E. King, III
Milestone: Boost 1.67.0 Component: date_time
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc:


boost::posix_time::from_time_t() uses a static_cast<long> to coerce the argument t to the appropriate type for the function seconds(), which expects a boost::int32_t. On an LP64 platform like MacOS 10.5, long is 64 bits, so this is incorrect and generates a warning about possible truncation. The corrected function should be:

  //! Function that converts a time_t into a ptime.
  ptime from_time_t(std::time_t t) 
    ptime start(gregorian::date(1970,1,1));
	return start + seconds(static_cast<boost::int32_t>(t));

Attachments (0)

Change History (4)

comment:1 Changed 14 months ago by anonymous

OMG, 8 years old! Any chance to be fixed in this decade?

comment:2 Changed 14 months ago by anonymous

There a fix for this in This can be closed as a duplicate of 4543, I believe.

comment:3 Changed 4 months ago by James E. King, III

Milestone: Boost 1.39.0Boost 1.67.0
Owner: changed from az_sw_dude to James E. King, III
Status: newassigned
Version: Boost Release BranchBoost 1.38.0

comment:4 Changed 4 months ago by James E. King, III

Resolution: fixed
Status: assignedclosed

Fix merged to master; resolved.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain James E. King, III.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.