#include <lldate.h>
Public Member Functions | |
LLDate () | |
Construct a date equal to epoch. | |
LLDate (const LLDate &date) | |
Construct a date equal to epoch. | |
LLDate (F64 seconds_since_epoch) | |
Construct a date from a seconds since epoch value. | |
LLDate (const std::string &iso8601_date) | |
Construct a date from a string representation. | |
std::string | asString () const |
Return the date as in ISO-8601 string. | |
std::string | asRFC1123 () const |
void | toStream (std::ostream &) const |
void | toHTTPDateStream (std::ostream &) const |
bool | fromString (const std::string &iso8601_date) |
Set the date from an ISO-8601 string. | |
bool | fromStream (std::istream &) |
F64 | secondsSinceEpoch () const |
Return the date in seconds since epoch. | |
void | secondsSinceEpoch (F64 seconds) |
Set the date in seconds since epoch. | |
Private Attributes | |
F64 | mSecondsSinceEpoch |
The date class represents a point in time after epoch - 1970-01-01.
Definition at line 47 of file lldate.h.
LLDate::LLDate | ( | ) |
LLDate::LLDate | ( | const LLDate & | date | ) |
LLDate::LLDate | ( | F64 | seconds_since_epoch | ) |
Construct a date from a seconds since epoch value.
seconds_since_epoch The number of seconds since UTC epoch.
Definition at line 58 of file lldate.cpp.
LLDate::LLDate | ( | const std::string & | iso8601_date | ) |
Construct a date from a string representation.
The date is constructed in the fromString()
method. See that method for details of supported formats. If that method fails to parse the date, the date is set to epoch.
iso8601_date | An iso-8601 compatible representation of the date. |
Definition at line 63 of file lldate.cpp.
References DATE_EPOCH, fromString(), llendl, llwarns, and mSecondsSinceEpoch.
std::string LLDate::asRFC1123 | ( | ) | const |
std::string LLDate::asString | ( | ) | const |
Return the date as in ISO-8601 string.
Definition at line 73 of file lldate.cpp.
References toStream().
bool LLDate::fromStream | ( | std::istream & | ) |
Definition at line 165 of file lldate.cpp.
References c, LL_APR_USEC_PER_SEC, and mSecondsSinceEpoch.
Referenced by fromString(), and operator>>().
bool LLDate::fromString | ( | const std::string & | iso8601_date | ) |
Set the date from an ISO-8601 string.
The parser only supports strings conforming to YYYYF-MM-DDTHH:MM:SS.FFZ where Y is year, M is month, D is day, H is hour, M is minute, S is second, F is sub-second, and all other characters are literal. If this method fails to parse the date, the previous date is retained.
iso8601_date | An iso-8601 compatible representation of the date. |
Definition at line 159 of file lldate.cpp.
References fromStream().
Referenced by LLDate().
Set the date in seconds since epoch.
seconds | The number of seconds since epoch UTC. |
Definition at line 232 of file lldate.cpp.
References mSecondsSinceEpoch.
F64 LLDate::secondsSinceEpoch | ( | ) | const |
Return the date in seconds since epoch.
Definition at line 227 of file lldate.cpp.
References mSecondsSinceEpoch.
Referenced by tut::ensure_equals().
void LLDate::toHTTPDateStream | ( | std::ostream & | ) | const |
Definition at line 92 of file lldate.cpp.
References LL_APR_USEC_PER_SEC, llendl, llinfos, months, mSecondsSinceEpoch, right, and weekdays.
Referenced by asRFC1123().
void LLDate::toStream | ( | std::ostream & | ) | const |
Definition at line 128 of file lldate.cpp.
References LL_APR_USEC_PER_SEC, mSecondsSinceEpoch, and right.
Referenced by asString(), and operator<<().
F64 LLDate::mSecondsSinceEpoch [private] |
Definition at line 116 of file lldate.h.
Referenced by fromStream(), LLDate(), secondsSinceEpoch(), toHTTPDateStream(), and toStream().