7#ifndef BOOST_LOCALE_DATE_TIME_HPP_INCLUDED
8#define BOOST_LOCALE_DATE_TIME_HPP_INCLUDED
10#include <boost/locale/date_time_facet.hpp>
11#include <boost/locale/formatting.hpp>
12#include <boost/locale/hold_ptr.hpp>
13#include <boost/locale/time_zone.hpp>
21# pragma warning(disable : 4275 4251 4231 4660)
24namespace boost {
namespace locale {
410 const size_t n =
size();
411 if(n < basic_.size())
414 periods_.push_back(f);
420 for(
size_t i = 0; i < basic_.size(); ++i) {
424 return basic_.size() + periods_.size();
431 throw std::out_of_range(
"Invalid index to date_time_period");
432 if(n < basic_.size())
435 return periods_[n - basic_.size()];
439 std::array<date_time_period, 4> basic_;
440 std::vector<date_time_period> periods_;
447 for(
unsigned i = 0; i < b.
size(); i++)
456 for(
unsigned i = 0; i < b.
size(); i++)
477 calendar(
const std::locale& l,
const std::string& zone);
601 void set(period::period_type f,
int v);
604 int get(period::period_type f) const;
606 int operator/(period::period_type f)
const {
return get(f); }
723 template<
typename CharType>
724 std::basic_ostream<CharType>&
operator<<(std::basic_ostream<CharType>& out,
const date_time& t)
726 const double time_point = t.time();
728 const uint64_t display_flags = info.display_flags();
729 if(as::detail::is_datetime_display_flags(display_flags)) {
732 info.display_flags(flags::datetime);
734 info.display_flags(display_flags);
742 template<
typename CharType>
747 if(as::detail::is_datetime_display_flags(display_flags)) {
760# pragma warning(push)
761# pragma warning(disable : 4512)
this class provides an access to general calendar information.
Definition: date_time.hpp:466
const std::string & get_time_zone() const
get calendar's time zone
calendar(const std::string &zone)
int greatest_minimum(period::period_type f) const
int maximum(period::period_type f) const
Get maximum value for period f, For example for Gregorian calendar's maximum period::day it is 31.
calendar & operator=(const calendar &other)
assign calendar
bool is_gregorian() const
Check if the calendar is Gregorian.
int least_maximum(period::period_type f) const
Get least maximum value for period f, For example for Gregorian calendar's maximum period::day it is ...
bool operator==(const calendar &other) const
Compare calendars for equivalence: i.e. calendar types, time zones etc.
int first_day_of_week() const
Get first day of week for specific calendar, for example for US it is 1 - Sunday for France it is 2 -...
int minimum(period::period_type f) const
Get minimum value for period f, For example for period::day it is 1.
calendar(std::ios_base &ios)
calendar(const std::locale &l)
calendar(const calendar &other)
copy calendar
bool operator!=(const calendar &other) const
Opposite of ==.
calendar(const std::locale &l, const std::string &zone)
const std::locale & get_locale() const
get calendar's locale
This class represents a period: a pair of two date_time objects.
Definition: date_time.hpp:770
const date_time & start() const
Get starting point.
Definition: date_time.hpp:782
date_time_duration(const date_time &first, const date_time &second)
Definition: date_time.hpp:774
const date_time & end() const
Get ending point.
Definition: date_time.hpp:784
int operator/(period::period_type f) const
Syntactic sugar for get(f)
Definition: date_time.hpp:779
int get(period::period_type f) const
find a difference in terms of period_type f
Definition: date_time.hpp:777
This error is thrown in case of invalid state that occurred.
Definition: date_time.hpp:31
date_time_error(const std::string &e)
Constructor of date_time_error class.
Definition: date_time.hpp:34
This class represents a set of periods.
Definition: date_time.hpp:396
date_time_period_set(period::period_type f)
Create a set of single period with value 1.
Definition: date_time.hpp:402
date_time_period_set()=default
Default constructor - empty set.
void add(date_time_period f)
Append date_time_period f to the set.
Definition: date_time.hpp:408
size_t size() const
Get number of items in list.
Definition: date_time.hpp:418
date_time_period_set(const date_time_period &fl)
Create a set of single period fl.
Definition: date_time.hpp:405
const date_time_period & operator[](size_t n) const
Get item at position n the set, n should be in range [0,size)
Definition: date_time.hpp:428
this class represents a date time and allows to perform various operation according to the locale set...
Definition: date_time.hpp:558
date_time operator-(const date_time_period &v) const
subtract date_time_period from the current date_time
bool operator>(const date_time &other) const
compare date_time in the timeline (ignores difference in calendar, timezone etc)
date_time & operator-=(const date_time_period_set &v)
subtract date_time_period_set v from the current date_time
date_time & operator-=(const date_time_period &v)
subtract date_time_period from the current date_time
date_time & operator+=(const date_time_period_set &v)
add date_time_period_set v to the current date_time
date_time operator+(period::period_type f) const
add single period f to the current date_time
Definition: date_time.hpp:609
date_time & operator>>=(const date_time_period &v)
roll current date_time backward by date_time_period v
date_time operator>>(const date_time_period_set &v) const
roll current date_time backward by date_time_period_set v
bool operator<=(const date_time &other) const
compare date_time in the timeline (ignores difference in calendar, timezone etc)
date_time(const date_time &other)
Copy a date_time.
std::string timezone() const
Get the name of the associated timezone.
bool is_in_daylight_saving_time() const
Check if *this time point is in daylight saving time.
date_time operator+(const date_time_period &v) const
add date_time_period to the current date_time
date_time operator>>(period::period_type f) const
roll backward a date by single period f.
Definition: date_time.hpp:620
bool operator<(const date_time &other) const
compare date_time in the timeline (ignores difference in calendar, timezone etc)
int difference(const date_time &other, period::period_type f) const
calculate the distance from this date_time to other in terms of periods f
date_time operator+(const date_time_period_set &v) const
add date_time_period_set v to the current date_time
date_time & operator<<=(const date_time_period &v)
roll current date_time forward by date_time_period v
bool operator!=(const date_time &other) const
compare date_time in the timeline (ignores difference in calendar, timezone etc)
date_time operator>>(const date_time_period &v) const
roll current date_time backward by date_time_period v
date_time operator<<(const date_time_period_set &v) const
roll current date_time forward by date_time_period_set v
date_time & operator-=(period::period_type f)
subtract single period f from the current date_time
Definition: date_time.hpp:615
int get(period::period_type f) const
get specific period f value
bool operator>=(const date_time &other) const
compare date_time in the timeline (ignores difference in calendar, timezone etc)
date_time operator<<(period::period_type f) const
roll forward a date by single period f.
Definition: date_time.hpp:618
int minimum(period::period_type f) const
Get minimal possible value for *this time point for a period f.
date_time & operator+=(const date_time_period &v)
add date_time_period to the current date_time
int maximum(period::period_type f) const
date_time & operator>>=(const date_time_period_set &v)
roll current date_time backward by date_time_period_set v
bool operator==(const date_time &other) const
compare date_time in the timeline (ignores difference in calendar, timezone etc)
date_time & operator+=(period::period_type f)
add single period f to the current date_time
Definition: date_time.hpp:613
date_time & operator<<=(period::period_type f)
roll forward a date by single period f.
Definition: date_time.hpp:622
date_time & operator>>=(period::period_type f)
roll backward a date by single period f.
Definition: date_time.hpp:624
void swap(date_time &other) noexcept
swaps two dates - efficient, does not throw
date_time operator-(period::period_type f) const
subtract single period f from the current date_time
Definition: date_time.hpp:611
date_time operator-(const date_time_period_set &v) const
subtract date_time_period_set v from the current date_time
date_time & operator<<=(const date_time_period_set &v)
roll current date_time forward by date_time_period_set v
date_time operator<<(const date_time_period &v) const
roll current date_time forward by date_time_period v
a smart pointer similar to std::unique_ptr but the underlying object has the same constness as the po...
Definition: hold_ptr.hpp:17
void display_flags(uint64_t flags)
Set flags that define how to format data, e.g. number, spell, currency etc.
static ios_info & get(std::ios_base &ios)
Get ios_info instance for specific stream object.
This class holds a type that represents certain period of time like year, hour, second and so on.
Definition: date_time_facet.hpp:66
date_time_period_set operator-(const date_time_period_set &a, const date_time_period_set &b)
Append two period sets when all periods of set change their sign.
Definition: date_time.hpp:453
date_time_period_set operator+(const date_time_period_set &a, const date_time_period_set &b)
Append two periods sets. Note this operator is not commutative.
Definition: date_time.hpp:444
std::basic_ostream< CharType > & operator<<(std::basic_ostream< CharType > &out, const date_time &t)
Definition: date_time.hpp:724
std::basic_istream< CharType > & operator>>(std::basic_istream< CharType > &in, date_time &t)
Definition: date_time.hpp:743
@ day_of_week_local
Local day of week, for example in France Monday is 1, in US Sunday is 1, [1..7].
Definition: date_time_facet.hpp:44
@ month
The month of year, calendar specific, in Gregorian [0..11].
Definition: date_time_facet.hpp:34
@ minute
minute [0..59]
Definition: date_time_facet.hpp:48
@ hour_12
12 clock hour [0..11]
Definition: date_time_facet.hpp:46
@ second
second [0..59]
Definition: date_time_facet.hpp:49
@ year
Year, it is calendar specific, for example 2011 in Gregorian calendar.
Definition: date_time_facet.hpp:32
@ day_of_year
The number of day in year, starting from 1, in Gregorian [1..366].
Definition: date_time_facet.hpp:36
@ week_of_year
The week number in the year.
Definition: date_time_facet.hpp:50
@ extended_year
Extended year for Gregorian/Julian calendars, where 1 BC == 0, 2 BC == -1.
Definition: date_time_facet.hpp:33
@ hour
24 clock hour [0..23]
Definition: date_time_facet.hpp:45
@ am_pm
am or pm marker [0..1]
Definition: date_time_facet.hpp:47
@ first_day_of_week
First day of week, constant, for example Sunday in US = 1, Monday in France = 2.
Definition: date_time_facet.hpp:52
@ week_of_month
The week number within current month.
Definition: date_time_facet.hpp:51
@ invalid
Special invalid value, should not be used directly.
Definition: date_time_facet.hpp:30
@ day
The day of month, calendar specific, in Gregorian [1..31].
Definition: date_time_facet.hpp:35
@ era
Era i.e. AC, BC in Gregorian and Julian calendar, range [0,1].
Definition: date_time_facet.hpp:31
@ day_of_week_in_month
Definition: date_time_facet.hpp:42
@ day_of_week
Definition: date_time_facet.hpp:37
period_type minute()
Get period_type for: minute [0..59].
Definition: date_time.hpp:128
period_type day_of_week_in_month()
Definition: date_time.hpp:103
date_time_period sunday()
Get predefined constant for Sunday.
Definition: date_time.hpp:307
date_time_period operator+(period::period_type f)
convert period_type to date_time_period(f,1)
Definition: date_time.hpp:353
period_type first_day_of_week()
Get period_type for: First day of week, constant, for example Sunday in US = 1, Monday in France = 2.
Definition: date_time.hpp:148
date_time_period april()
Get predefined constant for April.
Definition: date_time.hpp:261
date_time_period tuesday()
Get predefined constant for Tuesday.
Definition: date_time.hpp:317
date_time_period friday()
Get predefined constant for Friday.
Definition: date_time.hpp:332
period_type day_of_year()
Get period_type for: The number of day in year, starting from 1, in Gregorian [1.....
Definition: date_time.hpp:87
period_type hour()
Get period_type for: 24 clock hour [0..23].
Definition: date_time.hpp:113
date_time_period july()
Get predefined constant for July.
Definition: date_time.hpp:276
date_time_period may()
Get predefined constant for May.
Definition: date_time.hpp:266
date_time_period monday()
Get predefined constant for Monday.
Definition: date_time.hpp:312
period_type week_of_year()
Get period_type for: The week number in the year.
Definition: date_time.hpp:138
period_type day_of_week_local()
Get period_type for: Local day of week, for example in France Monday is 1, in US Sunday is 1,...
Definition: date_time.hpp:108
date_time_period pm()
Get predefined constant for PM (Post Meridiem)
Definition: date_time.hpp:347
date_time_period january()
Get predefined constant for January.
Definition: date_time.hpp:246
period_type am_pm()
Get period_type for: am or pm marker [0..1].
Definition: date_time.hpp:123
period_type era()
Get period_type for: Era i.e. AC, BC in Gregorian and Julian calendar, range [0,1].
Definition: date_time.hpp:62
period_type invalid()
Get period_type for: special invalid value, should not be used directly.
Definition: date_time.hpp:57
date_time_period am()
Get predefined constant for AM (Ante Meridiem)
Definition: date_time.hpp:342
period_type day()
Get period_type for: The day of month, calendar specific, in Gregorian [1..31].
Definition: date_time.hpp:82
date_time_period wednesday()
Get predefined constant for Wednesday.
Definition: date_time.hpp:322
date_time_period operator-(period::period_type f)
convert period_type to date_time_period(f,-1)
Definition: date_time.hpp:358
period_type year()
Get period_type for: Year, it is calendar specific, for example 2011 in Gregorian calendar.
Definition: date_time.hpp:67
period_type month()
Get period_type for: The month of year, calendar specific, in Gregorian [0..11].
Definition: date_time.hpp:77
date_time_period december()
Get predefined constant for December.
Definition: date_time.hpp:301
period_type week_of_month()
Get period_type for: The week number within current month.
Definition: date_time.hpp:143
date_time_period thursday()
Get predefined constant for Thursday.
Definition: date_time.hpp:327
date_time_period february()
Get predefined constant for February.
Definition: date_time.hpp:251
date_time_period november()
Get predefined constant for November.
Definition: date_time.hpp:296
date_time_period august()
Get predefined constant for August.
Definition: date_time.hpp:281
date_time_period june()
Get predefined constant for June.
Definition: date_time.hpp:271
date_time_period march()
Get predefined constant for March.
Definition: date_time.hpp:256
date_time_period saturday()
Get predefined constant for Saturday.
Definition: date_time.hpp:337
period_type day_of_week()
Definition: date_time.hpp:97
date_time_period october()
Get predefined constant for October.
Definition: date_time.hpp:291
date_time_period september()
Get predefined constant for September.
Definition: date_time.hpp:286
date_time_period operator*(period::period_type f, T v)
Create date_time_period of type f with value v.
Definition: date_time.hpp:365
period_type second()
Get period_type for: second [0..59].
Definition: date_time.hpp:133
period_type extended_year()
Get period_type for: Extended year for Gregorian/Julian calendars, where 1 BC == 0,...
Definition: date_time.hpp:72
period_type hour_12()
Get period_type for: 12 clock hour [0..11].
Definition: date_time.hpp:118
This class represents a pair of period_type and the integer values that describes its amount....
Definition: date_time.hpp:43
date_time_period operator-() const
Operator -, switches the sign of period.
Definition: date_time.hpp:49
date_time_period operator+() const
Operator + returns copy of itself.
Definition: date_time.hpp:47
date_time_period(period::period_type f=period::period_type(), int v=1)
Constructor that creates date_time_period from period_type f and a value v – default 1.
Definition: date_time.hpp:52
period::period_type type
The type of period, i.e. era, year, day etc.
Definition: date_time.hpp:44
int value
Definition: date_time.hpp:45