forked from HowardHinnant/date
Eschew using directives in headers, even at function scope.
* There is still an impact on user code, though I'm not sure if by specification or compiler bug. * Prefer using declarations instead.
This commit is contained in:
@ -1106,7 +1106,7 @@ typename std::enable_if
|
||||
>::type
|
||||
trunc(T t) NOEXCEPT
|
||||
{
|
||||
using namespace std;
|
||||
using std::numeric_limits;
|
||||
using I = typename choose_trunc_type<T>::type;
|
||||
CONSTDATA auto digits = numeric_limits<T>::digits;
|
||||
static_assert(digits < numeric_limits<I>::digits, "");
|
||||
@ -1197,7 +1197,8 @@ typename std::enable_if
|
||||
>::type
|
||||
trunc(const std::chrono::duration<Rep, Period>& d)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::duration;
|
||||
using rep = typename std::common_type<Rep, typename To::rep>::type;
|
||||
return To{detail::trunc(duration_cast<To>(duration_cast<duration<rep>>(d)).count())};
|
||||
}
|
||||
@ -1243,9 +1244,8 @@ typename std::enable_if
|
||||
>::type
|
||||
floor(const std::chrono::duration<Rep, Period>& d)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using rep = typename std::common_type<Rep, typename To::rep>::type;
|
||||
return floor<To>(floor<duration<rep>>(d));
|
||||
return floor<To>(floor<std::chrono::duration<rep>>(d));
|
||||
}
|
||||
|
||||
// round to nearest, to even on tie
|
||||
@ -3746,8 +3746,7 @@ public:
|
||||
|
||||
CONSTCD11 bool in_conventional_range() const NOEXCEPT
|
||||
{
|
||||
using namespace std::chrono;
|
||||
return sub_s_ < std::chrono::seconds{1} && s_ < minutes{1};
|
||||
return sub_s_ < std::chrono::seconds{1} && s_ < std::chrono::minutes{1};
|
||||
}
|
||||
|
||||
template <class CharT, class Traits>
|
||||
@ -3861,8 +3860,7 @@ public:
|
||||
|
||||
CONSTCD11 bool in_conventional_range() const NOEXCEPT
|
||||
{
|
||||
using namespace std;
|
||||
return !neg_ && h_ < days{1} && m_ < chrono::hours{1} &&
|
||||
return !neg_ && h_ < days{1} && m_ < std::chrono::hours{1} &&
|
||||
s_.in_conventional_range();
|
||||
}
|
||||
|
||||
@ -3873,14 +3871,12 @@ private:
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<(std::basic_ostream<charT, traits>& os, hh_mm_ss const& tod)
|
||||
{
|
||||
using namespace detail;
|
||||
using namespace std;
|
||||
if (tod.is_negative())
|
||||
os << '-';
|
||||
if (tod.h_ < chrono::hours{10})
|
||||
if (tod.h_ < std::chrono::hours{10})
|
||||
os << '0';
|
||||
os << tod.h_.count() << ':';
|
||||
if (tod.m_ < chrono::minutes{10})
|
||||
if (tod.m_ < std::chrono::minutes{10})
|
||||
os << '0';
|
||||
os << tod.m_.count() << ':' << tod.s_;
|
||||
return os;
|
||||
@ -3906,7 +3902,7 @@ CONSTCD14
|
||||
bool
|
||||
is_am(std::chrono::hours const& h) NOEXCEPT
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::hours;
|
||||
return hours{0} <= h && h < hours{12};
|
||||
}
|
||||
|
||||
@ -3915,7 +3911,7 @@ CONSTCD14
|
||||
bool
|
||||
is_pm(std::chrono::hours const& h) NOEXCEPT
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::hours;
|
||||
return hours{12} <= h && h < hours{24};
|
||||
}
|
||||
|
||||
@ -3924,7 +3920,7 @@ CONSTCD14
|
||||
std::chrono::hours
|
||||
make12(std::chrono::hours h) NOEXCEPT
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::hours;
|
||||
if (h < hours{12})
|
||||
{
|
||||
if (h == hours{0})
|
||||
@ -3943,7 +3939,7 @@ CONSTCD14
|
||||
std::chrono::hours
|
||||
make24(std::chrono::hours h, bool is_pm) NOEXCEPT
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::hours;
|
||||
if (is_pm)
|
||||
{
|
||||
if (h != hours{12})
|
||||
@ -4697,19 +4693,18 @@ template <class CharT, class Traits, class FwdIter>
|
||||
FwdIter
|
||||
scan_keyword(std::basic_istream<CharT, Traits>& is, FwdIter kb, FwdIter ke)
|
||||
{
|
||||
using namespace std;
|
||||
size_t nkw = static_cast<size_t>(std::distance(kb, ke));
|
||||
const unsigned char doesnt_match = '\0';
|
||||
const unsigned char might_match = '\1';
|
||||
const unsigned char does_match = '\2';
|
||||
unsigned char statbuf[100];
|
||||
unsigned char* status = statbuf;
|
||||
unique_ptr<unsigned char, void(*)(void*)> stat_hold(0, free);
|
||||
std::unique_ptr<unsigned char, void(*)(void*)> stat_hold(0, free);
|
||||
if (nkw > sizeof(statbuf))
|
||||
{
|
||||
status = (unsigned char*)malloc(nkw);
|
||||
status = (unsigned char*)std::malloc(nkw);
|
||||
if (status == nullptr)
|
||||
throw bad_alloc();
|
||||
throw std::bad_alloc();
|
||||
stat_hold.reset(status);
|
||||
}
|
||||
size_t n_might_match = nkw; // At this point, any keyword might match
|
||||
@ -4734,7 +4729,7 @@ scan_keyword(std::basic_istream<CharT, Traits>& is, FwdIter kb, FwdIter ke)
|
||||
auto ic = is.peek();
|
||||
if (ic == EOF)
|
||||
{
|
||||
is.setstate(ios::eofbit);
|
||||
is.setstate(std::ios::eofbit);
|
||||
break;
|
||||
}
|
||||
auto c = static_cast<char>(toupper(ic));
|
||||
@ -4794,7 +4789,7 @@ scan_keyword(std::basic_istream<CharT, Traits>& is, FwdIter kb, FwdIter ke)
|
||||
if (*st == does_match)
|
||||
break;
|
||||
if (kb == ke)
|
||||
is.setstate(ios_base::failbit);
|
||||
is.setstate(std::ios::failbit);
|
||||
return kb;
|
||||
}
|
||||
|
||||
@ -4808,9 +4803,20 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
const fields<Duration>& fds, const std::string* abbrev,
|
||||
const std::chrono::seconds* offset_sec)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using namespace detail;
|
||||
#if ONLY_C_LOCALE
|
||||
using detail::weekday_names;
|
||||
using detail::month_names;
|
||||
using detail::ampm_names;
|
||||
#endif
|
||||
using detail::save_ostream;
|
||||
using detail::get_units;
|
||||
using detail::extract_weekday;
|
||||
using detail::extract_month;
|
||||
using std::ios;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
using std::chrono::hours;
|
||||
date::detail::save_ostream<CharT, Traits> ss(os);
|
||||
os.fill(' ');
|
||||
os.flags(std::ios::skipws | std::ios::dec);
|
||||
@ -4818,7 +4824,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
tm tm{};
|
||||
bool insert_negative = fds.has_tod && fds.tod.to_duration() < Duration::zero();
|
||||
#if !ONLY_C_LOCALE
|
||||
auto& facet = use_facet<time_put<CharT>>(os.getloc());
|
||||
auto& facet = std::use_facet<std::time_put<CharT>>(os.getloc());
|
||||
#endif
|
||||
const CharT* command = nullptr;
|
||||
CharT modified = CharT{};
|
||||
@ -4837,7 +4843,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
return os;
|
||||
#if !ONLY_C_LOCALE
|
||||
const CharT f[] = {'%', *fmt};
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
#else // ONLY_C_LOCALE
|
||||
os << weekday_names().first[tm.tm_wday+7*(*fmt == 'a')];
|
||||
#endif // ONLY_C_LOCALE
|
||||
@ -4862,7 +4868,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
tm.tm_mon = static_cast<int>(extract_month(os, fds)) - 1;
|
||||
#if !ONLY_C_LOCALE
|
||||
const CharT f[] = {'%', *fmt};
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
#else // ONLY_C_LOCALE
|
||||
os << month_names().first[tm.tm_mon+12*(*fmt != 'B')];
|
||||
#endif // ONLY_C_LOCALE
|
||||
@ -4907,11 +4913,11 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
return os;
|
||||
tm.tm_yday = static_cast<int>((ld - local_days(ymd.year()/1/1)).count());
|
||||
CharT f[3] = {'%'};
|
||||
auto fe = begin(f) + 1;
|
||||
auto fe = std::begin(f) + 1;
|
||||
if (modified == CharT{'E'})
|
||||
*fe++ = modified;
|
||||
*fe++ = *fmt;
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), fe);
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), fe);
|
||||
#else // ONLY_C_LOCALE
|
||||
if (*fmt == 'c')
|
||||
{
|
||||
@ -4982,7 +4988,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
{
|
||||
tm.tm_year = y - 1900;
|
||||
CharT f[3] = {'%', 'E', 'C'};
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -5021,7 +5027,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
{
|
||||
tm.tm_mday = d;
|
||||
CharT f[3] = {'%', 'O', *fmt};
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -5152,7 +5158,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
{
|
||||
const CharT f[] = {'%', modified, *fmt};
|
||||
tm.tm_hour = static_cast<int>(hms.hours().count());
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -5224,7 +5230,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
{
|
||||
const CharT f[] = {'%', modified, *fmt};
|
||||
tm.tm_mon = static_cast<int>(m-1);
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -5261,7 +5267,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
{
|
||||
const CharT f[] = {'%', modified, *fmt};
|
||||
tm.tm_min = static_cast<int>(fds.tod.minutes().count());
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -5296,7 +5302,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
#if !ONLY_C_LOCALE
|
||||
const CharT f[] = {'%', *fmt};
|
||||
tm.tm_hour = static_cast<int>(fds.tod.hours().count());
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
#else
|
||||
if (is_am(fds.tod.hours()))
|
||||
os << ampm_names().first[0];
|
||||
@ -5350,7 +5356,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
tm.tm_hour = static_cast<int>(fds.tod.hours().count());
|
||||
tm.tm_min = static_cast<int>(fds.tod.minutes().count());
|
||||
tm.tm_sec = static_cast<int>(fds.tod.seconds().count());
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
#else
|
||||
hh_mm_ss<seconds> tod(duration_cast<seconds>(fds.tod.to_duration()));
|
||||
save_ostream<CharT, Traits> _(os);
|
||||
@ -5426,7 +5432,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
{
|
||||
const CharT f[] = {'%', modified, *fmt};
|
||||
tm.tm_sec = static_cast<int>(fds.tod.s_.seconds().count());
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -5489,7 +5495,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
{
|
||||
const CharT f[] = {'%', modified, *fmt};
|
||||
tm.tm_wday = static_cast<int>(wd);
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -5534,7 +5540,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
if (os.fail())
|
||||
return os;
|
||||
tm.tm_yday = static_cast<int>((ld - local_days(ymd.year()/1/1)).count());
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -5582,7 +5588,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
if (os.fail())
|
||||
return os;
|
||||
tm.tm_yday = static_cast<int>((ld - local_days(ymd.year()/1/1)).count());
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -5611,7 +5617,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
{
|
||||
const CharT f[] = {'%', modified, *fmt};
|
||||
tm.tm_wday = static_cast<int>(wd);
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
}
|
||||
#endif
|
||||
else
|
||||
@ -5659,7 +5665,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
if (os.fail())
|
||||
return os;
|
||||
tm.tm_yday = static_cast<int>((ld - local_days(ymd.year()/1/1)).count());
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -5684,11 +5690,11 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
tm.tm_min = static_cast<int>(fds.tod.minutes().count());
|
||||
tm.tm_hour = static_cast<int>(fds.tod.hours().count());
|
||||
CharT f[3] = {'%'};
|
||||
auto fe = begin(f) + 1;
|
||||
auto fe = std::begin(f) + 1;
|
||||
if (modified == CharT{'E'})
|
||||
*fe++ = modified;
|
||||
*fe++ = *fmt;
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), fe);
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), fe);
|
||||
#else
|
||||
os << fds.tod;
|
||||
#endif
|
||||
@ -5719,7 +5725,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
{
|
||||
const CharT f[] = {'%', modified, *fmt};
|
||||
tm.tm_year = y - 1900;
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
}
|
||||
#endif
|
||||
modified = CharT{};
|
||||
@ -5749,7 +5755,7 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
{
|
||||
const CharT f[] = {'%', modified, *fmt};
|
||||
tm.tm_year = static_cast<int>(y) - 1900;
|
||||
facet.put(os, os, os.fill(), &tm, begin(f), end(f));
|
||||
facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -5973,7 +5979,7 @@ std::basic_ostream<CharT, Traits>&
|
||||
to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
const sys_time<Duration>& tp)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using CT = typename std::common_type<Duration, seconds>::type;
|
||||
const std::string abbrev("UTC");
|
||||
CONSTDATA seconds offset{0};
|
||||
@ -6110,10 +6116,9 @@ template <class CharT, class Traits>
|
||||
long double
|
||||
read_long_double(std::basic_istream<CharT, Traits>& is, unsigned m = 1, unsigned M = 10)
|
||||
{
|
||||
using namespace std;
|
||||
unsigned count = 0;
|
||||
auto decimal_point = Traits::to_int_type(
|
||||
use_facet<numpunct<CharT>>(is.getloc()).decimal_point());
|
||||
std::use_facet<std::numpunct<CharT>>(is.getloc()).decimal_point());
|
||||
std::string buf;
|
||||
while (true)
|
||||
{
|
||||
@ -6292,9 +6297,14 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
fields<Duration>& fds, std::basic_string<CharT, Traits, Alloc>* abbrev,
|
||||
std::chrono::minutes* offset)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
typename basic_istream<CharT, Traits>::sentry ok{is, true};
|
||||
using std::numeric_limits;
|
||||
using std::ios;
|
||||
using std::chrono::duration;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
using std::chrono::hours;
|
||||
typename std::basic_istream<CharT, Traits>::sentry ok{is, true};
|
||||
if (ok)
|
||||
{
|
||||
date::detail::save_istream<CharT, Traits> ss(is);
|
||||
@ -6302,7 +6312,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
is.flags(std::ios::skipws | std::ios::dec);
|
||||
is.width(0);
|
||||
#if !ONLY_C_LOCALE
|
||||
auto& f = use_facet<time_get<CharT>>(is.getloc());
|
||||
auto& f = std::use_facet<std::time_get<CharT>>(is.getloc());
|
||||
std::tm tm{};
|
||||
#endif
|
||||
const CharT* command = nullptr;
|
||||
@ -6365,7 +6375,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
if (modified == CharT{})
|
||||
{
|
||||
#if !ONLY_C_LOCALE
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
is.setstate(err);
|
||||
if (!is.fail())
|
||||
@ -6397,7 +6407,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
if (!(1 <= trial_wd && trial_wd <= 7))
|
||||
{
|
||||
trial_wd = not_a_weekday;
|
||||
is.setstate(ios_base::failbit);
|
||||
is.setstate(ios::failbit);
|
||||
}
|
||||
else if (trial_wd == 7)
|
||||
trial_wd = 0;
|
||||
@ -6407,7 +6417,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
if (!(0 <= trial_wd && trial_wd <= 6))
|
||||
{
|
||||
trial_wd = not_a_weekday;
|
||||
is.setstate(ios_base::failbit);
|
||||
is.setstate(ios::failbit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6415,7 +6425,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
#if !ONLY_C_LOCALE
|
||||
else if (modified == CharT{'O'})
|
||||
{
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
is.setstate(err);
|
||||
if (!is.fail())
|
||||
@ -6443,7 +6453,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
{
|
||||
int ttm = not_a_month;
|
||||
#if !ONLY_C_LOCALE
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
if ((err & ios::failbit) == 0)
|
||||
ttm = tm.tm_mon + 1;
|
||||
@ -6471,7 +6481,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
if (modified != CharT{'O'})
|
||||
{
|
||||
#if !ONLY_C_LOCALE
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
if ((err & ios::failbit) == 0)
|
||||
{
|
||||
@ -6530,7 +6540,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
if (modified != CharT{'O'})
|
||||
{
|
||||
#if !ONLY_C_LOCALE
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
if ((err & ios::failbit) == 0)
|
||||
{
|
||||
@ -6566,7 +6576,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
if (modified != CharT{'O'})
|
||||
{
|
||||
#if !ONLY_C_LOCALE
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
if ((err & ios::failbit) == 0)
|
||||
{
|
||||
@ -6613,7 +6623,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
}
|
||||
else
|
||||
{
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
if ((err & ios::failbit) == 0)
|
||||
{
|
||||
@ -6695,7 +6705,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
#if !ONLY_C_LOCALE
|
||||
else if (modified == CharT{'O'})
|
||||
{
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
command = nullptr;
|
||||
width = -1;
|
||||
@ -6730,7 +6740,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
#if !ONLY_C_LOCALE
|
||||
else if (modified == CharT{'O'})
|
||||
{
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
if ((err & ios::failbit) == 0)
|
||||
checked_set(H, tm.tm_hour, not_a_hour, is);
|
||||
@ -6801,7 +6811,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
#if !ONLY_C_LOCALE
|
||||
else if (modified == CharT{'O'})
|
||||
{
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
if ((err & ios::failbit) == 0)
|
||||
checked_set(M, tm.tm_min, not_a_minute, is);
|
||||
@ -6833,7 +6843,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
#if !ONLY_C_LOCALE
|
||||
else if (modified == CharT{'O'})
|
||||
{
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
if ((err & ios::failbit) == 0)
|
||||
checked_set(m, tm.tm_mon + 1, not_a_month, is);
|
||||
@ -6860,9 +6870,9 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
auto ic = is.peek();
|
||||
if (Traits::eq_int_type(ic, Traits::eof()))
|
||||
{
|
||||
ios_base::iostate err = ios_base::eofbit;
|
||||
ios::iostate err = ios::eofbit;
|
||||
if (*fmt == 'n')
|
||||
err |= ios_base::failbit;
|
||||
err |= ios::failbit;
|
||||
is.setstate(err);
|
||||
break;
|
||||
}
|
||||
@ -6871,7 +6881,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
(void)is.get();
|
||||
}
|
||||
else if (*fmt == 'n')
|
||||
is.setstate(ios_base::failbit);
|
||||
is.setstate(ios::failbit);
|
||||
}
|
||||
else
|
||||
read(is, CharT{'%'}, width, modified, *fmt);
|
||||
@ -6891,7 +6901,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
#if !ONLY_C_LOCALE
|
||||
tm = std::tm{};
|
||||
tm.tm_hour = 1;
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
is.setstate(err);
|
||||
if (tm.tm_hour == 1)
|
||||
@ -6923,7 +6933,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
if (modified == CharT{})
|
||||
{
|
||||
#if !ONLY_C_LOCALE
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
if ((err & ios::failbit) == 0)
|
||||
{
|
||||
@ -7001,7 +7011,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
#if !ONLY_C_LOCALE
|
||||
else if (modified == CharT{'O'})
|
||||
{
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
if ((err & ios::failbit) == 0)
|
||||
checked_set(s, duration_cast<Duration>(seconds{tm.tm_sec}),
|
||||
@ -7060,7 +7070,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
#if !ONLY_C_LOCALE
|
||||
else if (modified == CharT{'E'})
|
||||
{
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
if ((err & ios::failbit) == 0)
|
||||
checked_set(Y, tm.tm_year + 1900, not_a_year, is);
|
||||
@ -7090,7 +7100,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
#if !ONLY_C_LOCALE
|
||||
else
|
||||
{
|
||||
ios_base::iostate err = ios_base::goodbit;
|
||||
ios::iostate err = ios::goodbit;
|
||||
f.get(is, nullptr, is, err, &tm, command, fmt+1);
|
||||
if ((err & ios::failbit) == 0)
|
||||
checked_set(Y, tm.tm_year + 1900, not_a_year, is);
|
||||
@ -7610,7 +7620,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
return is;
|
||||
}
|
||||
broken:
|
||||
is.setstate(ios_base::failbit);
|
||||
is.setstate(ios::failbit);
|
||||
return is;
|
||||
}
|
||||
|
||||
@ -7620,13 +7630,11 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, year& y,
|
||||
std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = seconds;
|
||||
using CT = std::chrono::seconds;
|
||||
fields<CT> fds{};
|
||||
from_stream(is, fmt, fds, abbrev, offset);
|
||||
if (!fds.ymd.year().ok())
|
||||
is.setstate(ios::failbit);
|
||||
is.setstate(std::ios::failbit);
|
||||
if (!is.fail())
|
||||
y = fds.ymd.year();
|
||||
return is;
|
||||
@ -7638,13 +7646,11 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, month& m,
|
||||
std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = seconds;
|
||||
using CT = std::chrono::seconds;
|
||||
fields<CT> fds{};
|
||||
from_stream(is, fmt, fds, abbrev, offset);
|
||||
if (!fds.ymd.month().ok())
|
||||
is.setstate(ios::failbit);
|
||||
is.setstate(std::ios::failbit);
|
||||
if (!is.fail())
|
||||
m = fds.ymd.month();
|
||||
return is;
|
||||
@ -7656,13 +7662,11 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, day& d,
|
||||
std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = seconds;
|
||||
using CT = std::chrono::seconds;
|
||||
fields<CT> fds{};
|
||||
from_stream(is, fmt, fds, abbrev, offset);
|
||||
if (!fds.ymd.day().ok())
|
||||
is.setstate(ios::failbit);
|
||||
is.setstate(std::ios::failbit);
|
||||
if (!is.fail())
|
||||
d = fds.ymd.day();
|
||||
return is;
|
||||
@ -7674,13 +7678,11 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, weekday& wd
|
||||
std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = seconds;
|
||||
using CT = std::chrono::seconds;
|
||||
fields<CT> fds{};
|
||||
from_stream(is, fmt, fds, abbrev, offset);
|
||||
if (!fds.wd.ok())
|
||||
is.setstate(ios::failbit);
|
||||
is.setstate(std::ios::failbit);
|
||||
if (!is.fail())
|
||||
wd = fds.wd;
|
||||
return is;
|
||||
@ -7692,13 +7694,11 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, year_month&
|
||||
std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = seconds;
|
||||
using CT = std::chrono::seconds;
|
||||
fields<CT> fds{};
|
||||
from_stream(is, fmt, fds, abbrev, offset);
|
||||
if (!fds.ymd.month().ok())
|
||||
is.setstate(ios::failbit);
|
||||
is.setstate(std::ios::failbit);
|
||||
if (!is.fail())
|
||||
ym = fds.ymd.year()/fds.ymd.month();
|
||||
return is;
|
||||
@ -7710,13 +7710,11 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, month_day&
|
||||
std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = seconds;
|
||||
using CT = std::chrono::seconds;
|
||||
fields<CT> fds{};
|
||||
from_stream(is, fmt, fds, abbrev, offset);
|
||||
if (!fds.ymd.month().ok() || !fds.ymd.day().ok())
|
||||
is.setstate(ios::failbit);
|
||||
is.setstate(std::ios::failbit);
|
||||
if (!is.fail())
|
||||
md = fds.ymd.month()/fds.ymd.day();
|
||||
return is;
|
||||
@ -7728,13 +7726,11 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
year_month_day& ymd, std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = seconds;
|
||||
using CT = std::chrono::seconds;
|
||||
fields<CT> fds{};
|
||||
from_stream(is, fmt, fds, abbrev, offset);
|
||||
if (!fds.ymd.ok())
|
||||
is.setstate(ios::failbit);
|
||||
is.setstate(std::ios::failbit);
|
||||
if (!is.fail())
|
||||
ymd = fds.ymd;
|
||||
return is;
|
||||
@ -7746,16 +7742,14 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
sys_time<Duration>& tp, std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = typename common_type<Duration, seconds>::type;
|
||||
minutes offset_local{};
|
||||
using CT = typename std::common_type<Duration, std::chrono::seconds>::type;
|
||||
std::chrono::minutes offset_local{};
|
||||
auto offptr = offset ? offset : &offset_local;
|
||||
fields<CT> fds{};
|
||||
fds.has_tod = true;
|
||||
from_stream(is, fmt, fds, abbrev, offptr);
|
||||
if (!fds.ymd.ok() || !fds.tod.in_conventional_range())
|
||||
is.setstate(ios::failbit);
|
||||
is.setstate(std::ios::failbit);
|
||||
if (!is.fail())
|
||||
tp = round<Duration>(sys_days(fds.ymd) - *offptr + fds.tod.to_duration());
|
||||
return is;
|
||||
@ -7767,14 +7761,12 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
local_time<Duration>& tp, std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = typename common_type<Duration, seconds>::type;
|
||||
using CT = typename std::common_type<Duration, std::chrono::seconds>::type;
|
||||
fields<CT> fds{};
|
||||
fds.has_tod = true;
|
||||
from_stream(is, fmt, fds, abbrev, offset);
|
||||
if (!fds.ymd.ok() || !fds.tod.in_conventional_range())
|
||||
is.setstate(ios::failbit);
|
||||
is.setstate(std::ios::failbit);
|
||||
if (!is.fail())
|
||||
tp = round<Duration>(local_seconds{local_days(fds.ymd)} + fds.tod.to_duration());
|
||||
return is;
|
||||
@ -7787,16 +7779,14 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using Duration = std::chrono::duration<Rep, Period>;
|
||||
using CT = typename common_type<Duration, seconds>::type;
|
||||
using CT = typename std::common_type<Duration, std::chrono::seconds>::type;
|
||||
fields<CT> fds{};
|
||||
from_stream(is, fmt, fds, abbrev, offset);
|
||||
if (!fds.has_tod)
|
||||
is.setstate(ios::failbit);
|
||||
is.setstate(std::ios::failbit);
|
||||
if (!is.fail())
|
||||
d = duration_cast<Duration>(fds.tod.to_duration());
|
||||
d = std::chrono::duration_cast<Duration>(fds.tod.to_duration());
|
||||
return is;
|
||||
}
|
||||
|
||||
@ -7932,9 +7922,8 @@ std::basic_ostream<CharT, Traits>&
|
||||
operator<<(std::basic_ostream<CharT, Traits>& os,
|
||||
const std::chrono::duration<Rep, Period>& d)
|
||||
{
|
||||
using namespace detail;
|
||||
return os << make_string<CharT, Traits>::from(d.count()) +
|
||||
get_units<CharT>(typename Period::type{});
|
||||
return os << detail::make_string<CharT, Traits>::from(d.count()) +
|
||||
detail::get_units<CharT>(typename Period::type{});
|
||||
}
|
||||
|
||||
} // namespace date
|
||||
|
@ -451,7 +451,7 @@ weekday::weekday(unsigned wd) NOEXCEPT
|
||||
CONSTCD11
|
||||
inline
|
||||
weekday::weekday(date::weekday wd) NOEXCEPT
|
||||
: wd_((wd-date::Monday).count() + 1)
|
||||
: wd_(wd.iso_encoding())
|
||||
{}
|
||||
|
||||
CONSTCD11
|
||||
@ -607,7 +607,10 @@ inline
|
||||
year
|
||||
year::min() NOEXCEPT
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
using std::chrono::hours;
|
||||
using std::chrono::duration_cast;
|
||||
static_assert(sizeof(seconds)*CHAR_BIT >= 41, "seconds may overflow");
|
||||
static_assert(sizeof(hours)*CHAR_BIT >= 30, "hours may overflow");
|
||||
return sizeof(minutes)*CHAR_BIT < 34 ?
|
||||
@ -620,7 +623,10 @@ inline
|
||||
year
|
||||
year::max() NOEXCEPT
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
using std::chrono::hours;
|
||||
using std::chrono::duration_cast;
|
||||
static_assert(sizeof(seconds)*CHAR_BIT >= 41, "seconds may overflow");
|
||||
static_assert(sizeof(hours)*CHAR_BIT >= 30, "hours may overflow");
|
||||
return sizeof(minutes)*CHAR_BIT < 34 ?
|
||||
|
@ -96,7 +96,10 @@ inline
|
||||
date::local_seconds
|
||||
rule::operator()(date::year y) const
|
||||
{
|
||||
using namespace date;
|
||||
using date::local_days;
|
||||
using date::January;
|
||||
using date::days;
|
||||
using date::last;
|
||||
using sec = std::chrono::seconds;
|
||||
date::local_seconds t;
|
||||
switch (mode_)
|
||||
@ -180,7 +183,9 @@ public:
|
||||
inline
|
||||
time_zone::time_zone(const detail::string_t& s)
|
||||
{
|
||||
using namespace detail;
|
||||
using detail::read_name;
|
||||
using detail::read_signed_time;
|
||||
using detail::throw_invalid;
|
||||
auto i = read_name(s, 0, std_abbrev_);
|
||||
i = read_signed_time(s, i, offset_);
|
||||
offset_ = -offset_;
|
||||
@ -212,8 +217,19 @@ template <class Duration>
|
||||
date::sys_info
|
||||
time_zone::get_info(date::sys_time<Duration> st) const
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
using date::sys_info;
|
||||
using date::year_month_day;
|
||||
using date::sys_seconds;
|
||||
using date::sys_days;
|
||||
using date::floor;
|
||||
using date::ceil;
|
||||
using date::days;
|
||||
using date::years;
|
||||
using date::year;
|
||||
using date::January;
|
||||
using date::December;
|
||||
using date::last;
|
||||
using std::chrono::minutes;
|
||||
sys_info r{};
|
||||
r.offset = offset_;
|
||||
if (start_rule_.ok())
|
||||
@ -256,9 +272,21 @@ template <class Duration>
|
||||
date::local_info
|
||||
time_zone::get_info(date::local_time<Duration> tp) const
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
using date::local_info;
|
||||
using date::year_month_day;
|
||||
using date::days;
|
||||
using date::sys_days;
|
||||
using date::sys_seconds;
|
||||
using date::years;
|
||||
using date::year;
|
||||
using date::ceil;
|
||||
using date::January;
|
||||
using date::December;
|
||||
using date::last;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
local_info r{};
|
||||
using date::floor;
|
||||
if (start_rule_.ok())
|
||||
{
|
||||
auto y = year_month_day{floor<days>(tp)}.year();
|
||||
@ -335,7 +363,9 @@ template <class Duration>
|
||||
date::sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
time_zone::to_sys(date::local_time<Duration> tp) const
|
||||
{
|
||||
using namespace date;
|
||||
using date::local_info;
|
||||
using date::sys_time;
|
||||
using date::ambiguous_local_time;
|
||||
auto i = get_info(tp);
|
||||
if (i.result == local_info::nonexistent)
|
||||
throw nonexistent_local_time(tp, i);
|
||||
@ -348,7 +378,9 @@ template <class Duration>
|
||||
date::sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
time_zone::to_sys(date::local_time<Duration> tp, date::choose z) const
|
||||
{
|
||||
using namespace date;
|
||||
using date::local_info;
|
||||
using date::sys_time;
|
||||
using date::choose;
|
||||
auto i = get_info(tp);
|
||||
if (i.result == local_info::nonexistent)
|
||||
{
|
||||
@ -366,8 +398,8 @@ template <class Duration>
|
||||
date::local_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
time_zone::to_local(date::sys_time<Duration> tp) const
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
using date::local_time;
|
||||
using std::chrono::seconds;
|
||||
using LT = local_time<typename std::common_type<Duration, seconds>::type>;
|
||||
auto i = get_info(tp);
|
||||
return LT{(tp + i.offset).time_since_epoch()};
|
||||
@ -404,7 +436,8 @@ inline
|
||||
unsigned
|
||||
read_date(const string_t& s, unsigned i, rule& r)
|
||||
{
|
||||
using namespace date;
|
||||
using date::month;
|
||||
using date::weekday;
|
||||
if (i == s.size())
|
||||
throw_invalid(s, i, "Expected rule but found end of string");
|
||||
if (s[i] == 'J')
|
||||
@ -513,7 +546,9 @@ inline
|
||||
unsigned
|
||||
read_unsigned_time(const string_t& s, unsigned i, std::chrono::seconds& t)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
using std::chrono::hours;
|
||||
if (i == s.size())
|
||||
throw_invalid(s, i, "Expected to read unsigned time, but found end of string");
|
||||
unsigned x;
|
||||
|
@ -891,8 +891,7 @@ inline
|
||||
sys_info
|
||||
time_zone::get_info(sys_time<Duration> st) const
|
||||
{
|
||||
using namespace std::chrono;
|
||||
return get_info_impl(date::floor<seconds>(st));
|
||||
return get_info_impl(date::floor<std::chrono::seconds>(st));
|
||||
}
|
||||
|
||||
template <class Duration>
|
||||
@ -900,8 +899,7 @@ inline
|
||||
local_info
|
||||
time_zone::get_info(local_time<Duration> tp) const
|
||||
{
|
||||
using namespace std::chrono;
|
||||
return get_info_impl(date::floor<seconds>(tp));
|
||||
return get_info_impl(date::floor<std::chrono::seconds>(tp));
|
||||
}
|
||||
|
||||
template <class Duration>
|
||||
@ -942,8 +940,6 @@ template <class Duration>
|
||||
sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
time_zone::to_sys_impl(local_time<Duration> tp, choose z, std::false_type) const
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
auto i = get_info(tp);
|
||||
if (i.result == local_info::nonexistent)
|
||||
{
|
||||
@ -961,8 +957,6 @@ template <class Duration>
|
||||
sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
time_zone::to_sys_impl(local_time<Duration> tp, choose, std::true_type) const
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
auto i = get_info(tp);
|
||||
if (i.result == local_info::nonexistent)
|
||||
throw nonexistent_local_time(tp, i);
|
||||
@ -1886,7 +1880,7 @@ template <class Duration>
|
||||
utc_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
utc_clock::from_sys(const sys_time<Duration>& st)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using CD = typename std::common_type<Duration, seconds>::type;
|
||||
auto const& leaps = get_tzdb().leaps;
|
||||
auto const lt = std::upper_bound(leaps.begin(), leaps.end(), st);
|
||||
@ -1900,8 +1894,7 @@ template <class Duration>
|
||||
std::pair<bool, std::chrono::seconds>
|
||||
is_leap_second(date::utc_time<Duration> const& ut)
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using duration = typename std::common_type<Duration, seconds>::type;
|
||||
auto const& leaps = get_tzdb().leaps;
|
||||
auto tp = sys_time<duration>{ut.time_since_epoch()};
|
||||
@ -1940,7 +1933,7 @@ template <class Duration>
|
||||
sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
utc_clock::to_sys(const utc_time<Duration>& ut)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using CD = typename std::common_type<Duration, seconds>::type;
|
||||
auto ls = is_leap_second(ut);
|
||||
auto tp = sys_time<CD>{ut.time_since_epoch() - ls.second};
|
||||
@ -1953,8 +1946,7 @@ inline
|
||||
utc_clock::time_point
|
||||
utc_clock::now()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
return from_sys(system_clock::now());
|
||||
return from_sys(std::chrono::system_clock::now());
|
||||
}
|
||||
|
||||
template <class Duration>
|
||||
@ -1977,7 +1969,7 @@ std::basic_ostream<CharT, Traits>&
|
||||
to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
const utc_time<Duration>& t)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using CT = typename std::common_type<Duration, seconds>::type;
|
||||
const std::string abbrev("UTC");
|
||||
CONSTDATA seconds offset{0};
|
||||
@ -2005,7 +1997,8 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
utc_time<Duration>& tp, std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
using CT = typename std::common_type<Duration, seconds>::type;
|
||||
minutes offset_local{};
|
||||
auto offptr = offset ? offset : &offset_local;
|
||||
@ -2027,7 +2020,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
is.setstate(std::ios::failbit);
|
||||
return is;
|
||||
}
|
||||
tp = time_point_cast<Duration>(tmp);
|
||||
tp = std::chrono::time_point_cast<Duration>(tmp);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
@ -2076,7 +2069,7 @@ inline
|
||||
utc_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
tai_clock::to_utc(const tai_time<Duration>& t) NOEXCEPT
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using CD = typename std::common_type<Duration, seconds>::type;
|
||||
return utc_time<CD>{t.time_since_epoch()} -
|
||||
(sys_days(year{1970}/January/1) - sys_days(year{1958}/January/1) + seconds{10});
|
||||
@ -2087,7 +2080,7 @@ inline
|
||||
tai_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
tai_clock::from_utc(const utc_time<Duration>& t) NOEXCEPT
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using CD = typename std::common_type<Duration, seconds>::type;
|
||||
return tai_time<CD>{t.time_since_epoch()} +
|
||||
(sys_days(year{1970}/January/1) - sys_days(year{1958}/January/1) + seconds{10});
|
||||
@ -2097,7 +2090,6 @@ inline
|
||||
tai_clock::time_point
|
||||
tai_clock::now()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
return from_utc(utc_clock::now());
|
||||
}
|
||||
|
||||
@ -2197,7 +2189,7 @@ inline
|
||||
utc_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
gps_clock::to_utc(const gps_time<Duration>& t) NOEXCEPT
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using CD = typename std::common_type<Duration, seconds>::type;
|
||||
return utc_time<CD>{t.time_since_epoch()} +
|
||||
(sys_days(year{1980}/January/Sunday[1]) - sys_days(year{1970}/January/1) +
|
||||
@ -2209,7 +2201,7 @@ inline
|
||||
gps_time<typename std::common_type<Duration, std::chrono::seconds>::type>
|
||||
gps_clock::from_utc(const utc_time<Duration>& t) NOEXCEPT
|
||||
{
|
||||
using namespace std::chrono;
|
||||
using std::chrono::seconds;
|
||||
using CD = typename std::common_type<Duration, seconds>::type;
|
||||
return gps_time<CD>{t.time_since_epoch()} -
|
||||
(sys_days(year{1980}/January/Sunday[1]) - sys_days(year{1970}/January/1) +
|
||||
@ -2220,7 +2212,6 @@ inline
|
||||
gps_clock::time_point
|
||||
gps_clock::now()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
return from_utc(utc_clock::now());
|
||||
}
|
||||
|
||||
|
@ -289,11 +289,9 @@ struct transition
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const transition& t)
|
||||
{
|
||||
using namespace date;
|
||||
using namespace std::chrono;
|
||||
using date::operator<<;
|
||||
os << t.timepoint << "Z ";
|
||||
if (t.info->offset >= seconds{0})
|
||||
if (t.info->offset >= std::chrono::seconds{0})
|
||||
os << '+';
|
||||
os << make_time(t.info->offset);
|
||||
if (t.info->is_dst > 0)
|
||||
|
Reference in New Issue
Block a user