C++ API Library Reference  4.3.2-74-ge1d4cca
Public Functions | Public Static Functions | List of all members
DateTime Class Reference

The DateTime class represents an instant in time from midnight of Jan 1, 0001 CE through 23:59:59 Dec 31, 9999 CE at a resolution of 100 nanoseconds (10e-7 seconds). It also contains a TimeSpan offset of the time relative to UTC.

Public Functions

DateTime Add (TimeSpan const &value) const
 
DateTime AddDays (double days) const
 
DateTime AddHours (double hours) const
 
DateTime AddMilliseconds (double milliseconds) const
 
DateTime AddMinutes (double minutes) const
 
DateTime AddMonths (int months) const
 
DateTime AddSeconds (double seconds) const
 
DateTime AddTicks (Int64 value) const
 
DateTime AddYears (int years) const
 
struct timespec AsTimespec () const
 
int Compare (DateTime const &other) const
 
DateTime Date () const
 
int Day () const
 
CSI::DayOfWeekEnum::Enum DayOfWeek () const
 
int DayOfYear () const
 
double FractionalSecond () const
 
int Hour () const
 
int Microsecond () const
 
int Millisecond () const
 
int Minute () const
 
int Month () const
 
TimeSpan Offset () const
 
bool operator!= (DateTime const &other) const
 
DateTime operator+ (TimeSpan const &value) const
 
DateTimeoperator+= (TimeSpan const &value)
 
DateTime operator- (TimeSpan const &value) const
 
TimeSpan operator- (DateTime const &other) const
 
DateTimeoperator-= (TimeSpan const &value)
 
bool operator< (DateTime const &other) const
 
bool operator<= (DateTime const &other) const
 
DateTimeoperator= (DateTime const &other)
 
bool operator== (DateTime const &other) const
 
bool operator> (DateTime const &other) const
 
bool operator>= (DateTime const &other) const
 
int Second () const
 
DateTime Subtract (TimeSpan const &value) const
 
TimeSpan Subtract (DateTime const &other) const
 
Int64 Ticks () const
 
TimeSpan TimeOfDay () const
 
DateTime ToLocalTime () const
 
DateTime ToOffset (TimeSpan const &offset) const
 
String ToString () const
 
double TotalDays () const
 
double TotalHours () const
 
double TotalMilliseconds () const
 
double TotalMinutes () const
 
double TotalSeconds () const
 
DateTime ToUniversalTime () const
 
Int64 UtcTicks () const
 
double UtcTotalDays () const
 
double UtcTotalHours () const
 
double UtcTotalMilliseconds () const
 
double UtcTotalMinutes () const
 
double UtcTotalSeconds () const
 
int Year () const
 
Constructors and Destructors
 DateTime ()
 
 DateTime (Int64 ticks)
 
 DateTime (TimeSpan const &offset, Int64 ticks)
 
 DateTime (struct timespec value)
 
 DateTime (TimeSpan const &offset, struct timespec value)
 
 DateTime (int year, int month, int day, int hour=0, int minute=0, int second=0, int millisecond=0)
 
 DateTime (TimeSpan const &offset, int year, int month, int day, int hour=0, int minute=0, int second=0, int millisecond=0)
 
 DateTime (DateTime const &other)
 
 ~DateTime ()
 

Public Static Functions

static int DaysInMonth (int year, int month)
 
static DateTime From (time_t value)
 
static bool IsLeapYear (int year)
 
static TimeSpan LocalOffset ()
 
static const DateTime MaxValue ()
 
static const DateTime MinValue ()
 
static DateTime Now ()
 
static DateTime Today ()
 
static bool TryParse (String const &value, DateTime &result)
 
static DateTime UtcNow ()
 

Usage Description

DateTime Add ( TimeSpan const &  value) const

Returns a DateTime instance which has the specified time span added to the current instance's date and time.

DateTime AddDays ( double  days) const

Returns a DateTime instance which has the specified number of days added to the current instance's date and time.

DateTime AddHours ( double  hours) const

Returns a DateTime instance which has the specified number of hours added to the current instance's date and time.

DateTime AddMilliseconds ( double  milliseconds) const

Returns a DateTime instance which has the specified number of milliseconds added to the current instance's date and time.

DateTime AddMinutes ( double  minutes) const

Returns a DateTime instance which has the specified number of minutes added to the current instance's date and time.

DateTime AddMonths ( int  months) const

Returns a DateTime instance which has the specified number of months added to the current instance's date and time.

DateTime AddSeconds ( double  seconds) const

Returns a DateTime instance which has the specified number of seconds added to the current instance's date and time.

DateTime AddTicks ( Int64  value) const

Returns a DateTime instance which has the specified number of ticks added to the current instance's date and time.

DateTime AddYears ( int  years) const

Returns a DateTime instance which has the specified number of years added to the current instance's date and time.

struct timespec AsTimespec ( ) const

Gets the current DateTime as a timespec.

int Compare ( DateTime const &  other) const

Compares the current instance to the specified instance.

DateTime Date ( ) const

Gets a DateTime representing the date component of the current instance. The returned instance's time will be set to midnight in the local time zone.

int Day ( ) const

Returns the day of the month component of the current instance.

CSI::DayOfWeekEnum::Enum DayOfWeek ( ) const

Returns the day of the week of the current instance.

int DayOfYear ( ) const

Returns the day of the year of the current instance in [1, 366].

static int DaysInMonth ( int  year,
int  month 
)
static

Gets the number of days in the specified month of the specified year.

double FractionalSecond ( ) const

Returns the fractional second component of the current instance's clock time.

static DateTime From ( time_t  value)
static
int Hour ( ) const

Returns the hour component of the current instance's clock time in [0, 23].

static bool IsLeapYear ( int  year)
static

Gets whether the specified year is a leap year.

static TimeSpan LocalOffset ( )
static

Gets a TimeSpan that represents the local offset from UTC.

static const DateTime MaxValue ( )
static

Returns an instance that represents the maximum DateTime value.

int Microsecond ( ) const

Returns the microsecond component of the current instance's clock time in [0, 999999].

int Millisecond ( ) const

Returns the millisecond component of the current instance's clock time in [0, 999].

int Minute ( ) const

Returns the minute component of the current instance's clock time in [0, 59].

static const DateTime MinValue ( )
static

Returns an instance that represents the minimum DateTime value.

int Month ( ) const

Returns the month component of the current instance in [1, 12].

static DateTime Now ( )
static

Gets a DateTime instance with its date and time set to the current local date and time and its offset to the local timezone's offset from UTC.

TimeSpan Offset ( ) const

Gets the current offset from UTC represented by the current instance.

bool operator!= ( DateTime const &  other) const
inline

Checks if the current instance is equal to the specified other instance. Returns true if they are not equal, otherwise returns false.

DateTime operator+ ( TimeSpan const &  value) const
inline

Arithmetic operator.

DateTime& operator+= ( TimeSpan const &  value)
inline

Arithmetic operator.

DateTime operator- ( TimeSpan const &  value) const
inline

Arithmetic operator.

TimeSpan operator- ( DateTime const &  other) const
inline

Arithmetic operator.

DateTime& operator-= ( TimeSpan const &  value)
inline

Arithmetic operator.

bool operator< ( DateTime const &  other) const
inline

Checks if the current instance is less than the specified other instance. Returns true if it is, otherwise returns false.

bool operator<= ( DateTime const &  other) const
inline

Checks if the current instance is less than or equal to the specified other instance. Returns true if it is, otherwise returns false.

DateTime& operator= ( DateTime const &  other)
bool operator== ( DateTime const &  other) const
inline

Checks if the current instance is equal to the specified other instance. Returns true if they are equal, otherwise returns false.

bool operator> ( DateTime const &  other) const
inline

Checks if the current instance is greater than the specified other instance. Returns true if it is, otherwise returns false.

bool operator>= ( DateTime const &  other) const
inline

Checks if the current instance is greater than or equal to the specified other instance. Returns true if it is, otherwise returns false.

int Second ( ) const

Returns the second component of the current instance's clock time in [0, 59].

DateTime Subtract ( TimeSpan const &  value) const

Returns a DateTime instance which has the specified time span removed from the current instance's date and time.

TimeSpan Subtract ( DateTime const &  other) const

Returns a TimeSpan instance which represents the amount of time elapsed from the current instance to the other instance.

Int64 Ticks ( ) const

Returns number of ticks represented by the current instance's clock time.

TimeSpan TimeOfDay ( ) const

Gets a TimeSpan representing the time component of the current instance.

static DateTime Today ( )
static

Gets a DateTime instance with its date set to the current date and its time set to midnight in the local time zone.

DateTime ToLocalTime ( ) const

Gets a DateTime representing the date and time of the current instance converted to local time. The returned instance's offset will the local offset from UTC.

DateTime ToOffset ( TimeSpan const &  offset) const

Returns a DateTime instance equivalent to the current instance, but with the specified offset.

String ToString ( ) const

Gets the current instance as a string. Format is YYYY-MM-DDThh:mm:ss[.fffffff]{-|+}hh:mm, or, for time with zero offset from UTC, YYYY-MM-DDThh:mm:ss[.fffffff]Z.

double TotalDays ( ) const

Returns number of days respresented by this instance's clock time.

double TotalHours ( ) const

Returns number of hours respresented by this instance's clock time.

double TotalMilliseconds ( ) const

Returns number of milliseconds respresented by this instance's clock time.

double TotalMinutes ( ) const

Returns number of minutes respresented by this instance's clock time.

double TotalSeconds ( ) const

Returns number of seconds respresented by this instance's clock time.

DateTime ToUniversalTime ( ) const

Gets a DateTime representing the date and time of the current instance converted to universal time. The returned instance's offset will be zero.

static bool TryParse ( String const &  value,
DateTime result 
)
static

Attempts to parse the specified string as a DateTime.

static DateTime UtcNow ( )
static

Gets a DateTime instance with its date and time set to the current UTC date and time and its offset set to zero.

Int64 UtcTicks ( ) const

Returns number of ticks in represented by the current instance's UTC time.

double UtcTotalDays ( ) const

Returns number of days respresented by this instance's UTC time.

double UtcTotalHours ( ) const

Returns number of hours respresented by this instance's UTC time.

double UtcTotalMilliseconds ( ) const

Returns number of milliseconds respresented by this instance's UTC time.

double UtcTotalMinutes ( ) const

Returns number of minutes respresented by this instance's UTC time.

double UtcTotalSeconds ( ) const

Returns number of seconds respresented by this instance's UTC time.

int Year ( ) const

Returns the year component of the current instance in [0, 9999].