Class DDateTime

Inherits from:
Object
Conforms to:
DComparable, DParsable, DTextable
Declared in:
DDateTime.h

Class Hierarchy

    Object
      |
      +---DDateTime

Class Description

The DDateTime class implements a date & time datatype.

Example:
#include <stdio.h>
#include "ofc/DDateTime.h"

int main(int argc, char *argv[])
{
  DDateTime *dtm1 = [DDateTime alloc];
  DDateTime *dtm2 = [DDateTime new  ];
  DText     *str;

  [dtm1 init :2008 :7 :20 :15 :3 :45]; // Init with a date and time

  [dtm2 time :16 :50 :8];              // Set the time
  [dtm2 date :2007 :12 :31];           // Set the date

  str = [dtm1 toISO8601];
  printf("Date1 in ISO8601 format:%s.\n", [str cstring]);
  [str free];

  [dtm2 localTime];                    // Set the date&time with localtime

  str = [dtm2 toASC];
  printf("LocalTime in asctime format:%s.\n", [str cstring]);
  [str free];

  [dtm2 UTCTime];                      // Set the date&time with UTC time
  str = [dtm2 format :"%a, %d-%b-%Y %H:%M:%S %z"];
  printf("UTCTime with format:%s.\n", [str cstring]);
  [str free];

  if ([dtm1 compare :dtm2] == 0)       // Compare two dates
    printf("Date1 is equal to date2.\n");
  else if ([dtm1 compare :dtm2] < 0)
    printf("Date1 is smaller than date2.\n");
  else
    printf("Date1 is greater than date2.\n");

  [dtm1 free];                         // Cleanup
  [dtm2 free];

  return 0;
}
Last modified:
23-Jul-2008 (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

Method Index


generated 06-Sep-2008 by ObjcDoc 3.0.0