Qtopia Home - Classes - Hierachy - Annotated - Functions - Qt Embedded |

# Calendar Class Reference

The Calendar class provides programmers with an easy to calculate and get information about dates, months and years. More...

`#include <qtopia/calendar.h>`

List of all member functions.

## Public Members

- class Day { }

## Static Public Members

- QValueList<Day> daysOfMonth ( int year, int month, bool startWithMonday = FALSE ) (obsolete)
- QString nameOfMonth ( int m )
- QString nameOfDay ( int d )
- QValueList<QDate> datesOfMonth ( int year, int month, bool startWithMonday = FALSE )
- QDate dateAtIndex ( int year, int month, int index, bool startWithMonday = FALSE )
- QDate dateAtCoord ( int year, int month, int row, int col, bool startWithMonday = FALSE )
- void coordForDate ( int year, int month, const QDate & date, int & row, int & col, bool startWithMonday = FALSE )
- int indexForDate ( int year, int month, const QDate & date, bool startWithMonday = FALSE )
- int weekInMonth ( const QDate & dt )
- QDate addMonths ( int nmonths, const QDate & orig )
- QDate addYears ( int nyears, const QDate & orig )

## Detailed Description

The Calendar class provides programmers with an easy to calculate and get information about dates, months and years.

See also Qtopia Classes.

## Member Function Documentation

### QDate Calendar::addMonths ( int nmonths, const QDate & orig )`[static]`

Returns a date nmonths later than the date orig (or earlier if nmonths is negative).

Rounds to the last day of month if the day of the calculated date would be invalid.

First availability: Qtopia 1.6

### QDate Calendar::addYears ( int nyears, const QDate & orig )`[static]`

Returns a date nyears later than the date orig (or earlier if nyears is negative).

First availability: Qtopia 1.6

### void Calendar::coordForDate ( int year, int month, const QDate & date, int & row, int & col, bool startWithMonday = FALSE )`[static]`

Sets the row and col to the position for date on the calendar page given by datesOfMonth() for the given year and month.

The page starts on the Monday on or before the 1st of the month if startWithMonday is TRUE, otherwise the page starts on the Sunday on or before the 1st of the month.

First availability: Qtopia 1.6

### QDate Calendar::dateAtCoord ( int year, int month, int row, int col, bool startWithMonday = FALSE )`[static]`

Using the calender page given by datesOfMonth() will return the date at the position row, col, for the given month and year.

The page starts on the Monday on or before the 1st of the month if startWithMonday is TRUE, otherwise the page starts on the Sunday on or before the 1st of the month.

First availability: Qtopia 1.6

### QDate Calendar::dateAtIndex ( int year, int month, int index, bool startWithMonday = FALSE )`[static]`

Using the calender page given by datesOfMonth() will return the date at the position index for the given month and year.

The page starts on the Monday on or before the 1st of the month if startWithMonday is TRUE, otherwise the page starts on the Sunday on or before the 1st of the month.

First availability: Qtopia 1.6

### QValueList<QDate> Calendar::datesOfMonth ( int year, int month, bool startWithMonday = FALSE )`[static]`

Returns a list of 42 dates (6 weeks) that cover the given month and year.

The list starts on the Monday on or before the 1st of the month if startWithMonday is TRUE, otherwise the list starts on the Sunday on or before the 1st of the month.

First availability: Qtopia 1.6

### QValueList<Day> Calendar::daysOfMonth ( int year, int month, bool startWithMonday = FALSE )`[static]`

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

### int Calendar::indexForDate ( int year, int month, const QDate & date, bool startWithMonday = FALSE )`[static]`

Returns the index for date on the calendar page given by datesOfMonth() for the given year and month.

The page starts on the Monday on or before the 1st of the month if startWithMonday is TRUE, otherwise the page starts on the Sunday on or before the 1st of the month.

First availability: Qtopia 1.6

### QString Calendar::nameOfDay ( int d )`[static]`

Returns the name of the day for d. Equivalent to QDate::dayName().

### QString Calendar::nameOfMonth ( int m )`[static]`

Returns the name of the month for m. Equivalent to QDate::monthName().

### int Calendar::weekInMonth ( const QDate & dt )`[static]`

Returns the week number the date dt is in the month for that date. For instance the first Wednesday of the month is in the first week the second Wednesday in the month is in the second week and so on.

First availability: Qtopia 1.6

This file is part of the Qtopia platform, copyright © 1995-2004 Trolltech, all rights reserved.