summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/timeconv.h
diff options
context:
space:
mode:
author Vas Crabb <cuavas@users.noreply.github.com>2021-08-22 09:06:15 +1000
committer GitHub <noreply@github.com>2021-08-22 09:06:15 +1000
commite8bbea1fc6e94e14768509d322f6c624403ffb36 (patch)
tree74dd1606a900d83de8aecff17a6737af4113308d /src/lib/util/timeconv.h
parente319bde5fc3696d7f48f62b15b6366c4377fe5d1 (diff)
formats, osd, util: Started refactoring file I/O stuff. (#8456)
Added more modern generic I/O interfaces with implementation backed by stdio, osd_file and core_file, replacing io_generic. Also replaced core_file's build-in zlib compression with a filter. unzip.cpp, un7z.cpp: Added option to supply abstract I/O interface rather than filename. Converted osd_file, core_file, archive_file, chd_file and device_image_interface to use std::error_condition rather than their own error enums. Allow mounting TI-99 RPK from inside archives.
Diffstat (limited to 'src/lib/util/timeconv.h')
-rw-r--r--src/lib/util/timeconv.h39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/lib/util/timeconv.h b/src/lib/util/timeconv.h
index f9d1b070012..91327dbac16 100644
--- a/src/lib/util/timeconv.h
+++ b/src/lib/util/timeconv.h
@@ -22,6 +22,7 @@
namespace util {
+
/***************************************************************************
GLOBAL VARIABLES
***************************************************************************/
@@ -58,7 +59,7 @@ struct arbitrary_datetime
// date of the epoch's begining
//---------------------------------------------------------
-template<typename Rep, int Y, int M, int D, int H, int N, int S, typename Ratio>
+template <typename Rep, int Y, int M, int D, int H, int N, int S, typename Ratio>
class arbitrary_clock
{
public:
@@ -89,7 +90,7 @@ public:
// with a different scale to this arbitrary_clock's scale
//---------------------------------------------------------
- template<typename Rep2, int YY, int MM, int DD, int HH, int NN, int SS, typename Ratio2>
+ template <typename Rep2, int YY, int MM, int DD, int HH, int NN, int SS, typename Ratio2>
static time_point from_arbitrary_time_point(const std::chrono::time_point<arbitrary_clock<Rep2, YY, MM, DD, HH, NN, SS, Ratio2> > &tp)
{
arbitrary_datetime dt;
@@ -111,7 +112,7 @@ public:
// of this scale to one of different scale
//---------------------------------------------------------
- template<typename Rep2, int YY, int MM, int DD, int HH, int NN, int SS, typename Ratio2>
+ template <typename Rep2, int YY, int MM, int DD, int HH, int NN, int SS, typename Ratio2>
static std::chrono::time_point<arbitrary_clock<Rep2, YY, MM, DD, HH, NN, SS, Ratio2> > to_arbitrary_time_point(const time_point &tp)
{
return arbitrary_clock<Rep2, YY, MM, DD, HH, NN, SS, Ratio2>::from_arbitrary_time_point(tp);
@@ -125,14 +126,14 @@ public:
static struct tm to_tm(const time_point &tp)
{
std::chrono::time_point<tm_conversion_clock> normalized_tp = to_arbitrary_time_point<
- std::int64_t,
- tm_conversion_clock::base_year,
- tm_conversion_clock::base_month,
- tm_conversion_clock::base_day,
- tm_conversion_clock::base_hour,
- tm_conversion_clock::base_minute,
- tm_conversion_clock::base_second,
- tm_conversion_clock::period>(tp);
+ std::int64_t,
+ tm_conversion_clock::base_year,
+ tm_conversion_clock::base_month,
+ tm_conversion_clock::base_day,
+ tm_conversion_clock::base_hour,
+ tm_conversion_clock::base_minute,
+ tm_conversion_clock::base_second,
+ tm_conversion_clock::period>(tp);
return internal_to_tm(normalized_tp.time_since_epoch());
}
@@ -144,14 +145,14 @@ public:
static std::chrono::time_point<std::chrono::system_clock> to_system_clock(const time_point &tp)
{
auto normalized_tp = to_arbitrary_time_point<
- std::int64_t,
- system_conversion_clock::base_year,
- system_conversion_clock::base_month,
- system_conversion_clock::base_day,
- system_conversion_clock::base_hour,
- system_conversion_clock::base_minute,
- system_conversion_clock::base_second,
- system_conversion_clock::period>(tp);
+ std::int64_t,
+ system_conversion_clock::base_year,
+ system_conversion_clock::base_month,
+ system_conversion_clock::base_day,
+ system_conversion_clock::base_hour,
+ system_conversion_clock::base_minute,
+ system_conversion_clock::base_second,
+ system_conversion_clock::period>(tp);
return std::chrono::time_point<std::chrono::system_clock>(normalized_tp.time_since_epoch() + system_clock_adjustment);
}