NCBI C++ ToolKit
|
Search Toolkit Book for CCurrentTime
#include <corelib/ncbitime.hpp>
Public Member Functions | |
CCurrentTime (ETimeZone tz=eLocal) | |
Constructor. More... | |
CCurrentTime & | Update (void) |
Update current time. More... | |
![]() | |
CTime (EInitMode mode=eEmpty, ETimeZone tz=eLocal, ETimeZonePrecision tzp=eTZPrecisionDefault) | |
Constructor. More... | |
CTime (time_t t, ETimeZonePrecision tzp=eTZPrecisionDefault) | |
Conversion constructor for time_t representation of time. More... | |
CTime (const struct tm &t, ETimeZonePrecision tzp=eTZPrecisionDefault) | |
Conversion constructor for "struct tm" local time representation. More... | |
CTime (int year, int month, int day, int hour=0, int minute=0, int second=0, long nanosecond=0, ETimeZone tz=eLocal, ETimeZonePrecision tzp=eTZPrecisionDefault) | |
Constructor. More... | |
CTime (int year, int yearDayNumber, ETimeZone tz=eLocal, ETimeZonePrecision tzp=eTZPrecisionDefault) | |
Constructor. More... | |
CTime (const string &str, const CTimeFormat &fmt=kEmptyStr, ETimeZone tz=eLocal, ETimeZonePrecision tzp=eTZPrecisionDefault) | |
Explicit conversion constructor for string representation of time. More... | |
CTime (const CTime &t) | |
Copy constructor. More... | |
CTime & | operator= (const CTime &t) |
Assignment operator. More... | |
CTime & | operator= (const string &str) |
Assignment operator from string. More... | |
CTime & | SetTimeT (const time_t t) |
Set time using time_t time value. More... | |
time_t | GetTimeT (void) const |
Get time in time_t format. More... | |
CTime & | SetTimeTM (const struct tm &t) |
Set time using "struct tm" time value. More... | |
struct tm | GetTimeTM (void) const |
Get time in "struct tm" format. More... | |
CTime & | SetTimeDBU (const TDBTimeU &t) |
Set time using database format time, TDBTimeU. More... | |
CTime & | SetTimeDBI (const TDBTimeI &t) |
Set time using database format time, TDBTimeI. More... | |
TDBTimeU | GetTimeDBU (void) const |
Get time in database format time, TDBTimeU. More... | |
TDBTimeI | GetTimeDBI (void) const |
Get time in database format time, TDBTimeI. More... | |
CTime & | SetCurrent (void) |
Make the time current in the presently active time zone. More... | |
CTime & | Clear (void) |
Make the time "empty",. More... | |
string | AsString (const CTimeFormat &format=kEmptyStr, TSeconds out_tz=eCurrentTimeZone) const |
Transform time to string. More... | |
operator string (void) const | |
Return time as string using the format returned by GetFormat(). More... | |
int | Year (void) const |
Get year. More... | |
int | Month (void) const |
Get month. More... | |
int | Day (void) const |
Get day. More... | |
int | Hour (void) const |
Get hour. More... | |
int | Minute (void) const |
Get minute. More... | |
int | Second (void) const |
Get second. More... | |
long | MilliSecond (void) const |
Get milliseconds. More... | |
long | MicroSecond (void) const |
Get microseconds. More... | |
long | NanoSecond (void) const |
Get nano-seconds. More... | |
void | SetYear (int year) |
Set year. More... | |
void | SetMonth (int month) |
Set month. More... | |
void | SetDay (int day) |
Set day. More... | |
void | SetHour (int hour) |
Set hour. More... | |
void | SetMinute (int minute) |
Set minute. More... | |
void | SetSecond (int second) |
Set second. More... | |
void | SetMilliSecond (long millisecond) |
Set milliseconds. More... | |
void | SetMicroSecond (long microsecond) |
Set microseconds. More... | |
void | SetNanoSecond (long nanosecond) |
Set nanoseconds. More... | |
int | YearDayNumber (void) const |
Get year's day number. More... | |
int | YearWeekNumber (EDayOfWeek first_day_of_week=eSunday) const |
Get this date's week number within the year. More... | |
int | MonthWeekNumber (EDayOfWeek first_day_of_week=eSunday) const |
Get this date's week number in the month. More... | |
int | DayOfWeek (void) const |
Get day of week. More... | |
int | DaysInMonth (void) const |
Get number of days in the month. More... | |
CTime & | AddYear (int years=1, EDaylight adl=eDaylightDefault) |
Add specified years and adjust for daylight saving time. More... | |
CTime & | AddMonth (int months=1, EDaylight adl=eDaylightDefault) |
Add specified months and adjust for daylight saving time. More... | |
CTime & | AddDay (int days=1, EDaylight adl=eDaylightDefault) |
Add specified days and adjust for daylight saving time. More... | |
CTime & | AddHour (int hours=1, EDaylight adl=eDaylightDefault) |
Add specified hours and adjust for daylight saving time. More... | |
CTime & | AddMinute (int minutes=1, EDaylight adl=eDaylightDefault) |
Add specified minutes and adjust for daylight saving time. More... | |
CTime & | AddSecond (TSeconds seconds=1, EDaylight adl=eDaylightDefault) |
Add specified seconds. More... | |
CTime & | AddNanoSecond (long nanoseconds=1) |
Add specified nanoseconds. More... | |
CTime & | AddTimeSpan (const CTimeSpan ×pan) |
Add specified time span. More... | |
CTime & | Round (ERoundPrecision precision=eRound_Day, EDaylight adl=eDaylightDefault) |
Round time. More... | |
CTime & | Truncate (ERoundPrecision precision=eRound_Day) |
Truncate time. More... | |
CTime & | operator+= (const CTimeSpan &ts) |
CTime & | operator-= (const CTimeSpan &ts) |
Operator to subtract time span. More... | |
CTime | operator+ (const CTimeSpan &ts) const |
CTime | operator- (const CTimeSpan &ts) const |
Operator to subtract time span. More... | |
CTimeSpan | operator- (const CTime &t) const |
Operator to subtract times. More... | |
bool | operator== (const CTime &t) const |
Operator to test equality of time. More... | |
bool | operator!= (const CTime &t) const |
Operator to test in-equality of time. More... | |
bool | operator> (const CTime &t) const |
Operator to test if time is later. More... | |
bool | operator< (const CTime &t) const |
Operator to test if time is earlier. More... | |
bool | operator>= (const CTime &t) const |
Operator to test if time is later or equal. More... | |
bool | operator<= (const CTime &t) const |
Operator to test if time is earlier or equal. More... | |
int | DiffWholeDays (const CTime &t) const |
Difference in whole days from specified time. More... | |
double | DiffDay (const CTime &t) const |
Difference in days from specified time. More... | |
double | DiffHour (const CTime &t) const |
Difference in hours from specified time. More... | |
double | DiffMinute (const CTime &t) const |
Difference in minutes from specified time. More... | |
TSeconds | DiffSecond (const CTime &t) const |
Difference in seconds from specified time. More... | |
double | DiffNanoSecond (const CTime &t) const |
Difference in nanoseconds from specified time. More... | |
CTimeSpan | DiffTimeSpan (const CTime &t) const |
Difference in nanoseconds from specified time. More... | |
bool | IsEmpty (void) const |
Is time object empty (date and time)? More... | |
bool | IsEmptyDate (void) const |
Is date empty? More... | |
bool | IsLeap (void) const |
Is time in a leap year? More... | |
bool | IsValid (void) const |
Is time valid? More... | |
bool | IsLocalTime (void) const |
Is time local time? More... | |
bool | IsUniversalTime (void) const |
Is time universal (GMT/UTC/Z)? More... | |
bool | IsGmtTime (void) const |
bool | IsDST (void) const |
Is DST (daylight savings time) in effect for this time? More... | |
ETimeZone | GetTimeZone (void) const |
Get time zone. More... | |
ETimeZone | GetTimeZoneFormat (void) const |
ETimeZone | SetTimeZone (ETimeZone val) |
Set time zone. More... | |
ETimeZone | SetTimeZoneFormat (ETimeZone val) |
ETimeZonePrecision | GetTimeZonePrecision (void) const |
Get time zone precision. More... | |
ETimeZonePrecision | SetTimeZonePrecision (ETimeZonePrecision val) |
Set time zone precision. More... | |
CTime | GetLocalTime (void) const |
Get the time as local time. More... | |
CTime | GetUniversalTime (void) const |
Get the time as universal (GMT/UTC) time. More... | |
CTime | GetGmtTime (void) const |
CTime & | ToTime (ETimeZone val) |
Convert the time into specified time zone time. More... | |
CTime & | ToLocalTime (void) |
Convert the time into local time. More... | |
CTime & | ToUniversalTime (void) |
Convert the time into universal (GMT/UTC) time. More... | |
CTime & | ToGmtTime (void) |
TSeconds | TimeZoneDiff (void) const |
Get difference between local timezone for current time object and UTC in seconds. More... | |
TSeconds | TimeZoneOffset (void) const |
Get difference between local timezone for current time object and UTC in seconds. More... | |
string | TimeZoneOffsetStr (void) |
Get time zone offset string in format [+/-]HHMM. More... | |
string | TimeZoneName (void) |
Get current time zone name. More... | |
Additional Inherited Members | |
![]() | |
enum | EInitMode { eCurrent , eEmpty } |
Which initial value to use for time. More... | |
enum | ETimeZone { eLocal = 1 , eUTC , eGmt = eUTC } |
Which initial value to use for timezone. More... | |
enum | { eCurrentTimeZone = -1 } |
Current timezone. Used in AsString() method. More... | |
enum | ENameFormat { eFull , eAbbr } |
Which format use to get name of month or week of day. More... | |
enum | EMonth { eJanuary = 1 , eFebruary , eMarch , eApril , eMay , eJune , eJuly , eAugust , eSeptember , eOctober , eNovember , eDecember } |
Month names. More... | |
enum | EDayOfWeek { eSunday = 0 , eMonday , eTuesday , eWednesday , eThursday , eFriday , eSaturday } |
Day of week names. More... | |
enum | ETimeZonePrecision { eNone , eMinute , eHour , eDay , eMonth , eTZPrecisionDefault = eNone } |
What time zone precision to use for adjusting daylight saving time. More... | |
enum | EDaylight { eIgnoreDaylight , eAdjustDaylight , eDaylightDefault = eAdjustDaylight } |
Whether to adjust for daylight saving time. More... | |
enum | ERoundPrecision { eRound_Day , eRound_Hour , eRound_Minute , eRound_Second , eRound_Millisecond , eRound_Microsecond } |
Precision for rounding time. More... | |
![]() | |
static void | GetCurrentTimeT (time_t *sec, long *nanosec=0) |
Get current UTC time in time_t format (with nanoseconds). More... | |
static void | SetFormat (const CTimeFormat &fmt) |
Set the current time format. More... | |
static CTimeFormat | GetFormat (void) |
Get the current time format. More... | |
static int | MonthNameToNum (const string &month) |
Get numerical value of the month by name. More... | |
static string | MonthNumToName (int month, ENameFormat format=eFull) |
Get name of the month by numerical value. More... | |
static int | DayOfWeekNameToNum (const string &day) |
Get numerical value of the day of week by name. More... | |
static string | DayOfWeekNumToName (int day, ENameFormat format=eFull) |
Get name of the day of week by numerical value. More... | |
static bool | ValidateString (const string &str, const CTimeFormat &fmt=kEmptyStr) |
Validate if string match time format. More... | |
CCurrentTime –.
Defines a wrapper for CTime class to represent a current time.
Getting current time is one of the most used operation with CTime, this wrapper allow to do it a bit easier and have cleaner code. If necessary, it allow to use any other CTime methods.
Definition at line 1282 of file ncbitime.hpp.