CppCMS

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
booster::locale::date_time Class Reference
Date, Time, Timezone and Calendar manipulations

this class represents a date time and allows to perform various operation according to the locale settings. More...

`#include <booster/booster/locale/date_time.h>`

## Public Member Functions
| date_time ()
| date_time (date_time const &other)
| date_time (date_time const &other, date_time_period_set const &set)
date_time const & | operator= (date_time const &other)
| date_time (double time)
| date_time (double time, calendar const &cal)
| date_time (calendar const &cal)
| date_time (date_time_period_set const &set)
| date_time (date_time_period_set const &set, calendar const &cal)
date_time const & | operator= (date_time_period_set const &f)
void | set (period::period_type f, int v)
int | get (period::period_type f) const
int | operator/ (period::period_type f) const
date_time | operator+ (period::period_type f) const
date_time | operator- (period::period_type f) const
date_time const & | operator+= (period::period_type f)
date_time const & | operator-= (period::period_type f)
date_time | operator<< (period::period_type f) const
date_time | operator>> (period::period_type f) const
date_time const & | operator<<= (period::period_type f)
date_time const & | operator>>= (period::period_type f)
date_time | operator+ (date_time_period const &v) const
date_time | operator- (date_time_period const &v) const
date_time const & | operator+= (date_time_period const &v)
date_time const & | operator-= (date_time_period const &v)
date_time | operator<< (date_time_period const &v) const
date_time | operator>> (date_time_period const &v) const
date_time const & | operator<<= (date_time_period const &v)
date_time const & | operator>>= (date_time_period const &v)
date_time | operator+ (date_time_period_set const &v) const
date_time | operator- (date_time_period_set const &v) const
date_time const & | operator+= (date_time_period_set const &v)
date_time const & | operator-= (date_time_period_set const &v)
date_time | operator<< (date_time_period_set const &v) const
date_time | operator>> (date_time_period_set const &v) const
date_time const & | operator<<= (date_time_period_set const &v)
date_time const & | operator>>= (date_time_period_set const &v)
double | time () const
void | time (double v)
bool | operator== (date_time const &other) const
bool | operator!= (date_time const &other) const
bool | operator< (date_time const &other) const
bool | operator> (date_time const &other) const
bool | operator<= (date_time const &other) const
bool | operator>= (date_time const &other) const
void | swap (date_time &other)
int | difference (date_time const &other, period::period_type f) const
int | minimum (period::period_type f) const
int | maximum (period::period_type f) const
bool | is_in_daylight_saving_time () const

## Detailed Description

this class represents a date time and allows to perform various operation according to the locale settings.

This class allows to manipulate various aspects of dates and times easily using arithmetic operations with periods.

General arithmetic functions:

- date_time + date_time_period_set = date_time: move time point forward by specific periods like date_time + month;
- date_time - date_time_period_set = date_time: move time point backward by specific periods like date_time - month;
- date_time << date_time_period_set = date_time: roll time point forward by specific periods with rolling to begin if overflows: like "2010-01-31" << 2* day == "2010-01-02" instead of "2010-02-02"
- date_time >> date_time_period_set = date_time: roll time point backward by specific periods with rolling to end if overflows: like "2010-01-02" >> 2* day == "2010-01-31" instead of "2009-12-30"
- date_time / period_type = int - current period value: like "2010-12-21" / month == 12. "2010-12-21" / year = 2010
- (date_time - date_time) / period_type = int: distance between dates in period_type. Like ("2010-12-01" - "2008-12-01") / month = 24.

You can also assign specific periods using assignment operator like: some_time = year * 1995 that sets the year to 1995.

## Constructor & Destructor Documentation

booster::locale::date_time::date_time | ( |  | ) |

Dafault constructor, uses default calendar initialized date_time object to current time.

Note
  throws std::bad_cast if the global locale does not have calendar_facet facet installed

booster::locale::date_time::date_time | ( | date_time const & | other | ) |

copy date_time

booster::locale::date_time::date_time | ( | date_time const & | other,
|  | date_time_period_set const & | set
| ) |  |

copy date_time and change some fields according to the set

booster::locale::date_time::date_time | ( | double | time | ) |

Create a date_time object using POSIX time time and default calendar

Note
  throws std::bad_cast if the global locale does not have calendar_facet facet installed

booster::locale::date_time::date_time | ( | double | time,
|  | calendar const & | cal
| ) |  |

Create a date_time object using POSIX time time and calendar cal

booster::locale::date_time::date_time | ( | calendar const & | cal | ) |

Create a date_time object using calendar cal and initializes it to current time.

booster::locale::date_time::date_time | ( | date_time_period_set const & | set | ) |

Create a date_time object using default calendar and define values given in set

Note
  throws std::bad_cast if the global locale does not have calendar_facet facet installed

booster::locale::date_time::date_time | ( | date_time_period_set const & | set,
|  | calendar const & | cal
| ) |  |

Create a date_time object using calendar cal and define values given in set

## Member Function Documentation

int booster::locale::date_time::difference | ( | date_time const & | other,
|  | period::period_type | f
| ) |  | const

calculate the distance from this date_time to other in terms of perios f

int booster::locale::date_time::get | ( | period::period_type | f | ) | const

get specific period f value

Referenced by booster::locale::period::am_pm(), booster::locale::period::day(), booster::locale::period::day_of_week(), booster::locale::period::day_of_week_in_month(), booster::locale::period::day_of_week_local(), booster::locale::period::day_of_year(), booster::locale::period::era(), booster::locale::period::extended_year(), booster::locale::period::first_day_of_week(), booster::locale::period::hour(), booster::locale::period::hour_12(), booster::locale::period::minute(), booster::locale::period::month(), booster::locale::period::second(), booster::locale::period::week_of_month(), booster::locale::period::week_of_year(), and booster::locale::period::year().

bool booster::locale::date_time::is_in_daylight_saving_time | ( |  | ) | const

Check if *this time point is in daylight saving time

int booster::locale::date_time::maximum | ( | period::period_type | f | ) | const

Get minimal possible value for *this time point for a period f. For example in February maximum(day) may be 28 or 29, in January maximum(day)==31

int booster::locale::date_time::minimum | ( | period::period_type | f | ) | const

Get minimal possible value for *this time point for a period f.

bool booster::locale::date_time::operator!= | ( | date_time const & | other | ) | const

compare date_time in the timeline (ignores difference in calendar, timezone etc)

date_time booster::locale::date_time::operator+ | ( | period::period_type | f | ) | const
| inline

add single period f to the current date_time

date_time booster::locale::date_time::operator+ | ( | date_time_period const & | v | ) | const

add date_time_period to the current date_time

date_time booster::locale::date_time::operator+ | ( | date_time_period_set const & | v | ) | const

add date_time_period_set v to the current date_time

date_time const& booster::locale::date_time::operator+= | ( | period::period_type | f | ) |
| inline

add single period f to the current date_time

date_time const& booster::locale::date_time::operator+= | ( | date_time_period const & | v | ) |

add date_time_period to the current date_time

date_time const& booster::locale::date_time::operator+= | ( | date_time_period_set const & | v | ) |

add date_time_period_set v to the current date_time

date_time booster::locale::date_time::operator- | ( | period::period_type | f | ) | const
| inline

subtract single period f from the current date_time

date_time booster::locale::date_time::operator- | ( | date_time_period const & | v | ) | const

subtract date_time_period from the current date_time

date_time booster::locale::date_time::operator- | ( | date_time_period_set const & | v | ) | const

subtract date_time_period_set v from the current date_time

date_time const& booster::locale::date_time::operator-= | ( | period::period_type | f | ) |
| inline

subtract single period f from the current date_time

date_time const& booster::locale::date_time::operator-= | ( | date_time_period const & | v | ) |

subtract date_time_period from the current date_time

date_time const& booster::locale::date_time::operator-= | ( | date_time_period_set const & | v | ) |

subtract date_time_period_set v from the current date_time

int booster::locale::date_time::operator/ | ( | period::period_type | f | ) | const
| inline

syntactic sugar for get(f)

bool booster::locale::date_time::operator< | ( | date_time const & | other | ) | const

compare date_time in the timeline (ignores difference in calendar, timezone etc)

date_time booster::locale::date_time::operator<< | ( | period::period_type | f | ) | const
| inline

roll forward a date by single period f.

date_time booster::locale::date_time::operator<< | ( | date_time_period const & | v | ) | const

roll current date_time forward by date_time_period v

date_time booster::locale::date_time::operator<< | ( | date_time_period_set const & | v | ) | const

roll current date_time forward by date_time_period_set v

date_time const& booster::locale::date_time::operator<<= | ( | period::period_type | f | ) |
| inline

roll forward a date by single period f.

date_time const& booster::locale::date_time::operator<<= | ( | date_time_period const & | v | ) |

roll current date_time forward by date_time_period v

date_time const& booster::locale::date_time::operator<<= | ( | date_time_period_set const & | v | ) |

roll current date_time forward by date_time_period_set v

bool booster::locale::date_time::operator<= | ( | date_time const & | other | ) | const

compare date_time in the timeline (ignores difference in calendar, timezone etc)

date_time const& booster::locale::date_time::operator= | ( | date_time const & | other | ) |

assign the date_time

date_time const& booster::locale::date_time::operator= | ( | date_time_period_set const & | f | ) |

assign values to various periods in set f

bool booster::locale::date_time::operator== | ( | date_time const & | other | ) | const

compare date_time in the timeline (ignores difference in calendar, timezone etc)

bool booster::locale::date_time::operator> | ( | date_time const & | other | ) | const

compare date_time in the timeline (ignores difference in calendar, timezone etc)

bool booster::locale::date_time::operator>= | ( | date_time const & | other | ) | const

compare date_time in the timeline (ignores difference in calendar, timezone etc)

date_time booster::locale::date_time::operator>> | ( | period::period_type | f | ) | const
| inline

roll backward a date by single period f.

date_time booster::locale::date_time::operator>> | ( | date_time_period const & | v | ) | const

roll current date_time backward by date_time_period v

date_time booster::locale::date_time::operator>> | ( | date_time_period_set const & | v | ) | const

roll current date_time backward by date_time_period_set v

date_time const& booster::locale::date_time::operator>>= | ( | period::period_type | f | ) |
| inline

roll backward a date by single period f.

References booster::locale::operator+(), booster::locale::operator-(), booster::locale::operator<<(), booster::locale::operator>>(), and booster::locale::as::time().

date_time const& booster::locale::date_time::operator>>= | ( | date_time_period const & | v | ) |

roll current date_time backward by date_time_period v

date_time const& booster::locale::date_time::operator>>= | ( | date_time_period_set const & | v | ) |

roll current date_time backward by date_time_period_set v

void booster::locale::date_time::set | ( | period::period_type | f,
|  | int | v
| ) |  |

set specific period f value to v

void booster::locale::date_time::swap | ( | date_time & | other | ) |

swaps two dates - efficient, does not throw

double booster::locale::date_time::time | ( |  | ) | const

Get POSIX time

The POSIX time is number of seconds since January 1st, 1970 00:00 UTC, ignoring leap seconds.

Referenced by booster::locale::operator<<(), and booster::locale::operator>>().

void booster::locale::date_time::time | ( | double | v | ) |

set POSIX time

The POSIX time is number of seconds since January 1st, 1970 00:00 UTC, ignoring leap seconds. This time can be fetched from Operating system clock using C function time, gettimeofday and others.

The documentation for this class was generated from the following file:

- booster/locale/date_time.h