28 using boost::posix_time::ptime;
29 using boost::posix_time::second_clock;
30 using boost::posix_time::from_iso_string;
31 using boost::posix_time::not_a_date_time;
38 ptime::operator=(second_clock::universal_time());
42 ptime::operator=(second_clock::local_time());
46 throw Exception(
"Invalid time zone specifier (%u)", (
uint) zone);
52 ptime::operator=(from_iso_string(value.
c_str()));
53 }
catch (std::exception &e) {
56 se.
add(
"Failed to create DateTime from \"%s\"", value.
c_str());
62 const UString sepStr(sep, sep ? 1 : 0);
65 (
int) date().year() , sepStr.
c_str(),
66 (int) date().month(), sepStr.
c_str(),
71 const UString sepStr(sep, sep ? 1 : 0);
74 (
int) time_of_day().hours() , sepStr.
c_str(),
75 (int) time_of_day().minutes(), sepStr.
c_str(),
76 (int) time_of_day().seconds());
80 const UString sepStr(sep, sep ? 1 : 0);
void add(const char *s,...) GCC_PRINTF(2
A class holding an UTF-8 string.
UString formatDateTimeISO(uint32 sep=0, uint32 sepDate=0, uint32 sepTime=0) const
Return a string representation of the date and time in ISO 8601 format.
Exception that provides a stack of explanations.
Utility functions for manipulating date and time.
Basic exceptions to throw.
const char * c_str() const
Return the (utf8 encoded) string data.
static UString format(const char *s,...) GCC_PRINTF(1
Print formatted data into an UString object, similar to sprintf().
The nondescript local time zone.
UString formatDateISO(uint32 sep=0) const
Return a string representation of the date in ISO 8601 format.
DateTime(TimeZone zone)
Create a DateTime object from the current date and time.
Coordinated Universal Time (UTC).
UString formatTimeISO(uint32 sep=0) const
Return a string representation of the time in ISO 8601 format.