- Inherits from:
- Object
- Conforms to:
- DComparable, DParsable, DTextable
- Declared in:
- DDateTime.h
Object
|
+---DDateTime
Class Description
The DDateTime class implements a date & time datatype.
- Last modified:
- 05-Nov-2007 (DDateTime.h)
Instance Variables
- private int _millis
- the milliseconds (0..999)
- private int _seconds
- the seconds (0..59)
- private int _minutes
- the minutes (0..59)
- private int _hours
- the hours (0..23)
- private int _day
- the day (1..31)
- private int _month
- the month (1..12)
- private int _year
- the year (1970..)
- private int _weekday
- the week day 0..6
- Constructors
- - (DDateTime *) init
- Initialise the object with a default date
- Returns:
- the object
- - (DDateTime *) init :(int) year :(int) month :(int) day :(int) hours :(int) minutes :(int) seconds
- Initialise with a date/time
- Parameters:
- year - the year (1970..)
month - the month (1..12)
day - the day (1..31)
hours - the hours (0..23)
minutes - the minutes (0..59)
seconds - the seconds (0..59)
- Returns:
- the object
- Member methods
- - (int) day
- Return the day
- Returns:
- the day (1..31)
- - (int) hours
- Return the hours
- Returns:
- the hours (0..23)
- - (int) millis
- Return the milliseconds
- Returns:
- the milliseconds (0..999)
- - (int) minutes
- Return the minutes
- Returns:
- the minutes (0..59)
- - (int) month
- Return the month
- Returns:
- the month (1..12)
- - (int) seconds
- Return the seconds
- Returns:
- the seconds (0..59)
- - (int) weekday
- Return the day of the week
- Returns:
- the day of the week (0..6)
- - (int) year
- Return the year
- Returns:
- the year (1970..)
- Class methods
- + (int) daysInMonth :(int) year :(int) month
- Return the number of days in a month
- Parameters:
- year - the year of the month
month - the month (1..12)
- Returns:
- the number of days in the month (1..31) or (-1)
- + (BOOL) isDateValid :(int) year :(int) month :(int) day
- Check if the date is valid
- Parameters:
- year - the year (1970..)
month - the month (1..12)
day - the day (1..31)
- Returns:
- is it ?
- + (BOOL) isLeapYear :(int) year
- Check if a year is a leap year
- Parameters:
- year - the year to be checked
- Returns:
- is it ?
- + (BOOL) isTimeValid :(int) hours :(int) minutes :(int) seconds :(int) millis
- Check if the time is valid
- Parameters:
- hours - the hours (0..23)
minutes - the minutes (0..59)
seconds - the seconds (0..59)
millis - the milliseconds (0..999)
- Returns:
- is it ?
- + (BOOL) isValid :(int) year :(int) month :(int) day :(int) hours :(int) minutes :(int) seconds :(int) millis
- Check if the date and time are valid
- Parameters:
- year - the year (1970..)
month - the month (1..12)
day - the day (1..31)
hours - the hours (0..23)
minutes - the minutes (0..59)
seconds - the seconds (0..59)
millis - the milliseconds (0..999)
- Returns:
- is it ?
- Set methods
- - (BOOL) UTCTime
- Set the object to the current UTC date/time
- Returns:
- success
- - (BOOL) date :(int) year :(int) month :(int) day
- Set the date
- Parameters:
- year - the year (1970..)
month - the month (1..12)
day - the day (1..31)
- Returns:
- success
- - (BOOL) localTime
- Set the object to the current local date/time
- Returns:
- success
- - (BOOL) norm
- Normalize the object
- Returns:
- success
- - (BOOL) set :(int) year :(int) month :(int) day :(int) hours :(int) minutes :(int) seconds
- Set the date/time
- Parameters:
- year - the year (1970..)
month - the month (1..12)
day - the day (1..31)
hours - the hours (0..23)
minutes - the minutes (0..59)
seconds - the seconds (0..59)
- Returns:
- success
- - (BOOL) set :(int) year :(int) month :(int) day :(int) hours :(int) minutes :(int) seconds :(int) millis
- Set the date/time
- Parameters:
- year - the year (1970..)
month - the month (1..12)
day - the day (1..31)
hours - the hours (0..23)
minutes - the minutes (0..59)
seconds - the seconds (0..59)
millis - the milliseconds (0..999)
- Returns:
- success
- - (BOOL) time :(int) hours :(int) minutes :(int) seconds
- Set the time
- Parameters:
- hours - the hours (0..23)
minutes - the minutes (0..59)
seconds - the seconds (0..59)
- Returns:
- success
- - (BOOL) time :(int) hours :(int) minutes :(int) seconds :(int) millis
- Set the time (incl. milliseconds)
- Parameters:
- hours - the hours (0..23)
minutes - the minutes (0..59)
seconds - the seconds (0..59)
millis - the milliseconds (0..999)
- Returns:
- success
- String output methods
- - (DText *) format :(const char *) format
- Format the date/time accordingly a format string (see strftime)
- Parameters:
- format - the format c-string
- Returns:
- a (new) text string object (or nil)
- - (DText *) toASC
- Format the date/time as returned by asctime
- Returns:
- a (new) text string object (or nil)
- - (DText *) toISO8601
- Format the date/time as specified in ISO 8601 (without the milliseconds and 'T' as separator)
- Returns:
- a (new) text string object
- - (DText *) toRFC1123
- Format the date/time as specified in RFC1123
- Returns:
- a (new) text string object (or nil)
- - (DText *) toRFC822
- Format the date/time as specified in RFC822
- Returns:
- a (new) text string object (or nil)
- - (DText *) toRFC850
- Format the date/time as specified in RFC850
- Returns:
- a (new) text string object (or nil)
- DTextable protocol implementation
- - (DText *) toText
- Format the date/time object as text (ISO 8601 format with milliseconds and ' ' as separator)
- Returns:
- a (new) text string object
- DParsable protocol implementation
- - (int) date :(char **) cstr
- Parse a string to set the object with a date.
This method supports the following format: (ISO 8061)
yyyy-mm-dd yy-mm-dd yyyymmdd yymmdd
- Parameters:
- cstr - the string to be parsed (moved to first non-parsable char)
- Returns:
- the result (0, ERANGE, ENODATA)
- - (BOOL) fromASC :(char **) cstr
- Parse the string with the format of asctime to set the date/time object (requires strptime)
- Parameters:
- cstr - the string to be parsed (moved to first non-parsable char)
- Returns:
- is the string parsed ?
- - (BOOL) fromRFC1123 :(char **) cstr
- Parse the string as specified in RFC1123 to set the date/time object (requires strptime)
- Parameters:
- cstr - the string to be parsed (moved to first non-parsable char)
- Returns:
- is the string parsed ?
- - (BOOL) fromRFC822 :(char **) cstr
- Parse the string as specified in RFC822 to set the date/time object (requires strptime)
- Parameters:
- cstr - the string to be parsed (moved to first non-parsable char)
- Returns:
- is the string parsed ?
- - (BOOL) fromRFC850 :(char **) cstr
- Parse the string as specified in RFC850 to set the date/time object (required strptime)
- Parameters:
- cstr - the string to be parsed (moved to first non-parsable char)
- Returns:
- is the string parsed ?
- - (int) fromString :(char **) cstr
- Parse a string to set a date time object.
This method supports the following format:
yyyy-mm-dd hh:mm:ss.mmm -- date/time accordingly ISO 8061
milliseconds are optional, also the separators
- Parameters:
- cstr - the string to be parsed (moved to first non-parsable char)
- Returns:
- the result (0, ERANGE, ENODATA)
- - (BOOL) parse :(char **) cstr :(const char *) format
- Parse a string with a format string to set the date/time object (requires strptime)
- Parameters:
- cstr - the string to be parsed (moved to the first non-parsable char)
format - the format for the string (see strptime)
- Returns:
- is the string parsed ?
- - (int) time :(char **) cstr
- Parse a string to set a date time object with a time.
This method supports the following format: (ISO 8061)
hh:mm:ss.mmm hh:mm:ss hhmmss.mmm hhmmss hh:mm hhmm
- Parameters:
- cstr - the string to be parsed (moved to first non-parsable char)
- Returns:
- the result (0, ERANGE, ENODATA)
- Comparable protocol implementation
- - (int) compare :(DDateTime *) other
- Compare the DateTime object with another DateTime object
- Parameters:
- other - the object that should be compared
- Returns:
- the compare result (-1, 0, 1)
generated 05-Nov-2007 by ObjcDoc 3.0.0