Minor fixes

This commit is contained in:
Howard Hinnant 2016-04-21 16:21:01 -04:00
parent d8426940d7
commit 95271f8337
2 changed files with 15 additions and 3 deletions

12
date.h
View File

@ -3,7 +3,7 @@
// The MIT License (MIT)
//
// Copyright (c) 2015 Howard Hinnant
// Copyright (c) 2015, 2016 Howard Hinnant
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -989,6 +989,13 @@ ceil(const std::chrono::time_point<Clock, FromDuration>& tp)
return time_point<Clock, To>{ceil<To>(tp.time_since_epoch())};
}
#else // _MSC_FULL_VER < 190023918
using std::chrono::floor;
using std::chrono::ceil;
using std::chrono::round;
using std::chrono::abs;
#endif // _MSC_FULL_VER < 190023918
// trunc towards zero
@ -3578,7 +3585,8 @@ public:
os << std::abs(t.sub_s_.count()) * scale::num / scale::den;
#else // __cplusplus >= 201402
// inefficient sub-optimal run-time mess, but gets the job done
const unsigned long long cl10 = std::ceil(log10(Period::den));
const unsigned long long cl10 =
static_cast<unsigned long long>(std::ceil(log10(Period::den)));
const auto p10 = std::pow(10., cl10);
os.width(cl10);
os << static_cast<unsigned long long>(std::abs(t.sub_s_.count())

6
tz.h
View File

@ -85,6 +85,10 @@ static_assert(HAS_REMOTE_API == 0 ? AUTO_DOWNLOAD == 0 : true,
#include <type_traits>
#include <utility>
#include <vector>
#if LAZY_INIT
# include <memory>
# include <mutex>
#endif
namespace date
{
@ -738,7 +742,7 @@ format(const std::locale& loc, std::string format,
using namespace std;
using namespace std::chrono;
for (auto i = 0; i < format.size(); ++i)
for (std::size_t i = 0; i < format.size(); ++i)
{
if (format[i] == '%' && i < format.size()-1)
{