Algorithmic Solutions > LEDA > LEDA Guide > Simple, Basic, and Advanced Data Types > Simple Data Types >Date

Date

The data type date represents a date consisting of day, month, and year. The data type provides many operations and is very convenient to use. A comprehensive description of the date type and the available operations can be found on the date manual page.

Example

The following example shows how date can be used in a program.

#include <LEDA/system/date.h>

using namespace leda;

int main()
{
  //define date and different output formats
  date D(2,date::month(11), 1973);
  date::set_output_format(date::german_standard);
  std::cout << D << std::endl;  //prints "02.11.1973"
  
  D.set_date(12,date::Nov,2011);
  date::set_language(date::english);
  date::set_output_format("dth M yyyy");
  std::cout << D << std::endl;  //prints "12th November 2011"
  
  //count number of sundays between today and 1.1.2010
  int number_of_sundays=0;
  for (date D2;D2<=date(1,date::Jan,2010);++D2)
    if (D2.get_day_of_week()==7) ++number_of_sundays;
  std::cout << "number_of_sundays=" << number_of_sundays << std::endl;
  
  return 0;
}

See also:

Manual Page Date




Please send any suggestions, comments or questions to leda@algorithmic-solutions.com
© Copyright 2001-2003, Algorithmic Solutions Software GmbH