|
static constexpr JulianDayNumber | ToJulianRep (month m, day d, year y, DataExchange::ValidationStrategy validationStrategy=DataExchange::ValidationStrategy::eAssertion) |
|
static constexpr year_month_day | FromJulianRep (JulianDayNumber j, DataExchange::ValidationStrategy validationStrategy=DataExchange::ValidationStrategy::eAssertion) |
|
static Date | Now () noexcept |
|
static Date | Parse (const String &rep, const locale &l=locale{}) |
|
static optional< Date > | ParseQuietly (const String &rep, const String &formatPattern) |
| like Parse(), but returns nullopt on parse error, not throwing exception. if locale is missing, and formatPattern is not locale independent, the current locale (locale{}) is used. if rep is empty, this will return nullopt
|
|
static days | Since (Date dStart, Date dEnd) |
|
Description: The Date class is (originally) based on SmallTalk-80, The Language & Its Implementation, page 108 (apx) - but changed to use Gregorian instead of Julian calendar.
- Note
- This class integrates neatly with the C++20 chrono date support. You can easily go back and forth (e.g. Date{std::chrono::year_month_day...}} or d.As<year_month_day> ())
The main features of the Stroika Data class (compared to the std c++ date support):
o Simpler to use/understand (Stroika 'Date' does about the same thing as a bevy of
different chrono classes)
o Stroika Date immutable (OK - difference not clearly advantage)
o Validation (constructor DataExchange::ValidationStrategy)
(no non-ok () Date objects in Stroika). Nice clear semantics about exceptions
and assertions.
o Easier to use formatting
o ISO8601 formatting
o Wraps needlessly complicated locale/facet API for formatting dates as Strings, or
parsing them from strings.
o Builtin support for Julian calendar (again - maybe this is a difference not advantage?)
- Note
- o Date stores date's internally as Julian days, and so is valid for any date > January 1, −4713; Also note sizeof (year_month_day) == sizeof (Date) == 4
- Miscellaneous references
- o According to https://en.wikipedia.org/wiki/Gregorian_calendar Britain and the British Empire (including the eastern part of what is now the United States) adopted the Gregorian calendar in 1752 o https://aa.usno.navy.mil/data/JulianDate Best Julian date calculator I found (bad but best) o Proleptic Gregorian Calendar https://en.wikipedia.org/wiki/Gregorian_calendar#Proleptic_Gregorian_calendar o Julian Day Numer https://en.wikipedia.org/wiki/Julian_day
Class Date knows about some obvious information: -> there are seven days in a week, each day having a symbolic name and an index 1..7 -> there are twelve months in a year, each having a symbolic name and an index 1..12. -> months have 28..31 days and -> a particular year might be a leap year."
@iverbatim
NB: Date implies NO NOTION of timezone.
@endiverbatim
\note The entire Date API is immutable - meaning that all methods are const (except constructor and assignment operator)
\note Date constructors REQUIRE valid inputs, and any operations which might overflow throw range_error
instead of creating invalid values.
\note Would like to make Date inherit from Debug::AssertExternallySynchronizedMutex to assure its not accidentially modified, but
that's difficult because its sometimes uses as a constexpr
\note \em Thread-Safety <a href="Thread-Safety.md#C++-Standard-Thread-Safety">C++-Standard-Thread-Safety</a>
\note <a href="Design-Overview.md#Comparisons">Comparisons: static_assert (totally_ordered<Date>);
Definition at line 327 of file Date.h.
DisplayFormat is a representation which a date can be transformed in and out of.
eCurrentLocale_WithZerosStripped eCurrentLocale_WithZerosStripped is locale{}, but with many cases of leading zero's, stripped, so for example, 03/05/2013 becomes 3/5/2013. This only affects the day/month, and not the year.
- Note
- Common::DefaultNames<> supported
Definition at line 587 of file Date.h.
constexpr ReferencePoint Stroika::Foundation::Time::Date::kGregorianCalendarEpoch {1752y / September / 14d, 2361222} |
|
staticconstexpr |
See https://en.wikipedia.org/wiki/Gregorian_calendar September, 14d, 1752 (even this not sure of, but used this in Stroika v2.1)
"Algorithm 199 from Communications of the ACM, Volume 6, No. 8,
(Aug. 1963), p. 444. Gregorian calendar started on Sep. 14, 1752"
Definition at line 376 of file Date.h.