IMAP4 has its own format for date-time strings. An example date-time string is this: "24-May-2002 13:50:04 -0400".
IMAP4 uses a date-time string for the internal date attribute of a message, which typically indicates the time that a message was first added to the server's message store.
An Imap4Date can be valid, invalid, or null. Valid means that the Imap4Date has a value that is valid. Invalid means that the Imap4Date was assigned a date, but that the date was invalid. Normally, this means that the library was unable to parse the assigned date-time string. You may call the IsValid() member function to learn if an Imap4Date object is valid or invalid. Null means that the Imap4Date object was never assigned a value. You might find a null Imap4Date if you examine a FetchResponse: if a FETCH response from the IMAP4 server does not have an InternalDate value, then the function FetchResponse::InternalDate() returns a null Imap4Date. You may call the IsNull() member function to learn if an Imap4Date object is null.
If you want to keep your code simple, then you may decide to treat all Imap4Date objects the same way, even the ones that have invalid or null values. The library assigns the date 1 Jan 1970 00:00:00 +0000 to an invalid or null Imap4Date. The corresponding scalar value is zero. Note, however, if the library fails to parse a date-time string, it marks the Imap4Date object as invalid and sets the date value to 1 Jan 1970 00:00:00 +0000, but it does not change the assigned date-time string. Therefore, if you have a better parser, you may get the original date-time string and parse it yourself. Also note that the string value of a null Imap4Date is a zero-length string.
To use Imap4Date to parse an IMAP4 date-time string, use the constructor that takes a string argument to create an Imap4Date object. You may call the IsValid() member function to learn if the library successfully parsed the date-time string. You may then call other member functions to get the year, month, day, hour, minute, second, and zone.
To use Imap4Date to generate an IMAP4 date-time string, use the constructor that takes values for the year, month, day, hour, minute, second, and zone. You may then call the String() member function to get the generated date-time string.
The AsScalar() member function returns a scalar value that you may use to compare two date values. The scalar value is the number of seconds since 1 Jan 1970 00:00:00 UTC, which is commensurate with the value returned from the C library's time() on most Unix systems. The scalar value is valid for dates between the year 1970 and the year 2038.
Imap4Date has a copy constructor and an assignment operator, so you may treat Imap4Date objects as value objects.
Public Member Functions | |
| Imap4Date () | |
| Default constructor. | |
| Imap4Date (const Imap4Date &other) | |
| Copy constructor. | |
| Imap4Date (int) | |
| Constructor that sets the value to null. | |
| Imap4Date (const char *str) | |
| Constructor that takes an initial string value. | |
| Imap4Date (int year, int month, int day, int hour, int minute, int second, int zone) | |
| Constructor that takes an initial date value. | |
| Imap4Date & | operator= (const Imap4Date &other) |
| Assignment operator. | |
| bool | IsValid () const |
| Returns true if the last parse succeeded. | |
| bool | IsNull () const |
| Returns true if the value is null. | |
| const char * | String () const |
| Gets the IMAP4 date as a string. | |
| int | Year () const |
| Gets the year. | |
| int | Month () const |
| Gets the month. | |
| int | Day () const |
| Gets the day. | |
| int | Hour () const |
| Gets the hour. | |
| int | Minute () const |
| Gets the minute. | |
| int | Second () const |
| Gets the second. | |
| int | Zone () const |
| Gets the zone. | |
| unsigned | AsScalar () const |
| Returns a scalar value. | |
|
|
Constructor that creates an Imap4Date with the current date and time. This constructor gets the date, time, and zone from the operating system to set the Imap4Date's value. |
|
|
Copy constructor.
|
|
|
Constructor that creates a null Imap4Date. A null Imap4Date represents a date that was never assigned a value. The library uses this constructor to construct an Imap4Date object that is part of a FetchResponse if the server's FETCH response does not have an InternalDate value. |
|
|
Constructor that takes a date-time string value. The constructor parses the date-time string argument. You may call the IsValid() member function after this constructor to learn if the constructor parsed the date-time string successfullly. If the parsing succeeded, IsValid() returns true. An example valid date-time string is this: 24-May-2002 13:50:04 -0400
|
|
||||||||||||||||||||||||||||||||
|
Constructor that takes a date-time value. The constructor generates a valid date-time string using the argument values.
|
|
|
Gets the scalar value. The scalar value is the number of seconds since 1 Jan 1970 00:00:00 UTC, which is commensurate with the scalar value of the C library's time() function on most Unix systems. The scalar value is useful for comparing two different dates. Although you may use the Imap4Date class to represent dates from 1900 to 2100, you may call this member function only for dates in the range 1970 to 2038.
|
|
|
Assignment operator.
|
Copyright © 2001-2005 Hunny Software, Inc. All rights reserved.