DateTimeFormat Class Reference
A formatter for dates and times.
More...
#include <DateTimeFormat.h++>
List of all members.
Classes |
| class | Token |
Public Member Functions |
| | DateTimeFormat (String format="%t %T", String dateFormat="%t", String timeFormat="%T") |
| | Construct a new DateTimeFormat.
|
| | ~DateTimeFormat () throw () |
| | Destructor.
|
| void | setFormat (const String &format) |
| | Set the format for dates with times.
|
| void | setDateFormat (const String &dateFormat) |
| | Set the format for dates.
|
| void | setTimeFormat (const String &timeFormat) |
| | Set the format for times.
|
| String | format (const Date &value) const |
| | Format a Date.
|
| size_t | format (const Date &value, char *buf, size_t bufsz) const |
| | Format a DateTime.
|
| String | format (const Time &value) const |
| | Format a Time.
|
| size_t | format (const Time &value, char *buf, size_t bufsz) const |
| | Format a DateTime.
|
| String | format (const DateTime &value) const |
| | Format a DateTime.
|
| size_t | format (const DateTime &value, char *buf, size_t bufsz) const |
| | Format a DateTime.
|
| void | parse (Date &value, const String &text) const throw (ParseException) |
| | Parse a Date from a string.
|
| void | parse (Time &value, const String &text) const throw (ParseException) |
| | Parse a Time from a string.
|
| void | parse (DateTime &value, const String &text) const throw (ParseException) |
| | Parse a DateTime from a string.
|
Detailed Description
A formatter for dates and times.
Available format directives are enumerated below. Unrecognized directives are ignored, and all other text is treated literally.
| Directive | Meaning | Range |
| %H | Hour of 24-hour clock | 0 - 23 |
| %0H | Hour of 24-hour clock (padded with leading zeroes) | 00 - 23 |
| %_H | Hour of 24-hour clock (padded with leading spaces) | 0 - 23 |
| %h | Hour of 12-hour clock | 1 - 12 |
| %0h | Hour of 12-hour clock (padded with leading zeroes) | 01 - 12 |
| %_h | Hour of 12-hour clock (padded with leading spaces) | 1 - 12 |
| %M | Minutes (unpadded) | 0 - 59 |
| %0M | Minutes (padded with leading zeroes) | 00 - 59 |
| %_M | Minutes (padded with leading spaces) | 0 - 59 |
| %S | Seconds (unpadded) | 0 - 60 |
| %0S | Seconds (padded with leading zeroes) | 00 - 60 |
| %_S | Seconds (padded with leading spaces) | 0 - 60 |
| %s | Milliseconds (unpadded) | 0 - 999 |
| %0s | Milliseconds (padded with leading zeroes) | 000 - 999 |
| %_s | Milliseconds (padded with leading spaces) | 0 - 999
|
| %d | Day of month | 1 - 31 |
| %0d | Day of month (padded with leading zeroes) | 01 - 31 |
| %_d | Day of month (padded with leading spaces) | 1 - 31
|
| %D | Day of year | 1 - 366 |
| %0D | Day of year (padded with leading zeroes) | 001 - 366 |
| %_D | Day of year (padded with leading spaces) | 1 - 366
|
| %m | Month number (1 = January) | 1 - 12 |
| %0m | Month number (1 = January) (padded with leading zeroes) | 01 - 12 |
| %_m | Month number (1 = January) (padded with leading spaces) | 1 - 12 |
| %$m | Abbreviated month name |
| %$$m | Full month name |
| %w | Weekday number (0 = Sunday) | 0 - 6 |
| %$w | Abbreviated weekday name |
| %$$w | Full weekday name
|
| %W | Week number (ISO standard) | 0 - 52 |
| %0W | Week number (ISO standard) (padded with leading zeroes) | 00 - 52 |
| %_w | Week number (ISO standard) (padded with leading spaces) | 0 - 52
|
| %y | 2-digit year | 0 - 99 |
| %0y | 2-digit year (padded with leading zeroes) | 00 - 99 |
| %_y | 2-digit year (padded with leading spaces) | 0 - 99 |
| %Y | 4-digit year | 0 - 9999 |
| %0Y | 4-digit year (padded with leading zeroes) | 0000 - 9999 |
| %_Y | 4-digit year (padded with leading spaces) | 0 - 9999
|
| %P | Meridiem (uppercase) (local form of "AM" or "PM") |
| %p | Meridiem (lowercase) (local form of "am" or "pm") |
| %t | Date |
| %T | Time |
| %Z | Time zone name |
| %% | Percent sign |
- Author:
- Mark Lindner
Constructor & Destructor Documentation
Construct a new DateTimeFormat.
- Parameters:
-
| format | The format for dates with times. |
| dateFormat | The format for dates. |
| timeFormat | The format for times. |
Member Function Documentation
| size_t format |
( |
const DateTime & |
value, |
|
|
char * |
buf, |
|
|
size_t |
bufsz | |
|
) |
| | const |
Format a DateTime.
- Parameters:
-
| value | The DateTime to format. |
| buf | A raw character buffer to write the formatted value to. |
| bufsz | The size of the character buffer. |
- Returns:
- The number of characters written to the buffer.
Format a DateTime.
- Parameters:
-
- Returns:
- The formatted string representation of the date & time.
| size_t format |
( |
const Time & |
value, |
|
|
char * |
buf, |
|
|
size_t |
bufsz | |
|
) |
| | const |
Format a DateTime.
- Parameters:
-
| value | The Time to format. |
| buf | A raw character buffer to write the formatted value to. |
| bufsz | The size of the character buffer. |
- Returns:
- The number of characters written to the buffer.
Format a Time.
- Parameters:
-
| value | The Time to format. |
- Returns:
- The formatted string representation of the time.
| size_t format |
( |
const Date & |
value, |
|
|
char * |
buf, |
|
|
size_t |
bufsz | |
|
) |
| | const |
Format a DateTime.
- Parameters:
-
| value | The Date to format. |
| buf | A raw character buffer to write the formatted value to. |
| bufsz | The size of the character buffer. |
- Returns:
- The number of characters written to the buffer.
Format a Date.
- Parameters:
-
| value | The Date to format. |
- Returns:
- The formatted string representation of the date.
Parse a DateTime from a string.
- Parameters:
-
| value | The value to parse into. |
| text | The string to parse. |
- Exceptions:
-
Parse a Time from a string.
- Parameters:
-
| value | The value to parse into. |
| text | The string to parse. |
- Exceptions:
-
Parse a Date from a string.
- Parameters:
-
| value | The value to parse into. |
| text | The string to parse. |
- Exceptions:
-
| void setDateFormat |
( |
const String & |
dateFormat |
) |
[inline] |
Set the format for dates.
| void setFormat |
( |
const String & |
format |
) |
[inline] |
Set the format for dates with times.
| void setTimeFormat |
( |
const String & |
timeFormat |
) |
[inline] |
Set the format for times.
The documentation for this class was generated from the following files: