mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-01 11:44:26 +02:00
add c_encoding and iso_encoding weekday functions (#380)
- c_encoding satisfies ctime wday encoding: days since Sunday, range [0,6] - iso_encoding satisfies ISO 8601 weekday: a digit d from 1 through 7, beginning with Monday and ending with Sunday
This commit is contained in:
committed by
Howard Hinnant
parent
90d0440884
commit
4e7e76b981
@@ -429,6 +429,9 @@ public:
|
||||
|
||||
CONSTCD11 bool ok() const NOEXCEPT;
|
||||
|
||||
CONSTCD11 unsigned c_encoding() const NOEXCEPT;
|
||||
CONSTCD11 unsigned iso_encoding() const NOEXCEPT;
|
||||
|
||||
CONSTCD11 weekday_indexed operator[](unsigned index) const NOEXCEPT;
|
||||
CONSTCD11 weekday_last operator[](last_spec) const NOEXCEPT;
|
||||
|
||||
@@ -1763,6 +1766,20 @@ weekday::operator-=(const days& d) NOEXCEPT
|
||||
|
||||
CONSTCD11 inline bool weekday::ok() const NOEXCEPT {return wd_ <= 6;}
|
||||
|
||||
CONSTCD11
|
||||
inline
|
||||
unsigned weekday::c_encoding() const NOEXCEPT
|
||||
{
|
||||
return unsigned{wd_};
|
||||
}
|
||||
|
||||
CONSTCD11
|
||||
inline
|
||||
unsigned weekday::iso_encoding() const NOEXCEPT
|
||||
{
|
||||
return unsigned{((wd_ == 0u) ? 7u : wd_)};
|
||||
}
|
||||
|
||||
CONSTCD11
|
||||
inline
|
||||
bool
|
||||
|
Reference in New Issue
Block a user