DAW JSON Link
daw_json_link_types_iso8601.h
Go to the documentation of this file.
1 // Copyright (c) Darrell Wright
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
5 //
6 // Official repository: https://github.com/beached/daw_json_link
7 //
8 
9 #pragma once
10 
11 #include "daw_json_enums.h"
12 #include "daw_json_parse_digit.h"
15 #include "version.h"
16 
17 #include <daw/daw_string_view.h>
18 #include <daw/daw_utility.h>
19 
20 #include <chrono>
21 #include <ciso646>
22 #include <optional>
23 #include <string_view>
24 
25 namespace daw::json {
26  inline namespace DAW_JSON_VER {
27  template<JsonNullable>
29  using result_type =
30  std::optional<std::chrono::time_point<std::chrono::system_clock,
31  std::chrono::milliseconds>>;
32 
33  [[maybe_unused, nodiscard]] inline constexpr result_type
34  operator( )( ) const {
35  return { };
36  }
37 
38  [[maybe_unused, nodiscard]] inline constexpr result_type
39  operator( )( char const *ptr, std::size_t sz ) const {
40  return datetime::parse_iso8601_timestamp( daw::string_view( ptr, sz ) );
41  }
42  };
43 
44  template<>
46  using result_type = std::chrono::time_point<std::chrono::system_clock,
47  std::chrono::milliseconds>;
48 
49  [[maybe_unused, nodiscard]] inline constexpr result_type
50  operator( )( char const *ptr, std::size_t sz ) const {
51  return datetime::parse_iso8601_timestamp( daw::string_view( ptr, sz ) );
52  }
53  };
54 
55  } // namespace DAW_JSON_VER
56 } // namespace daw::json
constexpr std::chrono::time_point< std::chrono::system_clock, std::chrono::milliseconds > parse_iso8601_timestamp(daw::basic_string_view< char, Bounds, Ex > ts)
Definition: daw_json_parse_iso8601_utils.h:220
JsonNullable
Definition: daw_json_enums.h:77
Definition: daw_from_json.h:22
std::chrono::time_point< std::chrono::system_clock, std::chrono::milliseconds > result_type
Definition: daw_json_link_types_iso8601.h:47
Definition: daw_json_link_types_iso8601.h:28
std::optional< std::chrono::time_point< std::chrono::system_clock, std::chrono::milliseconds > > result_type
Definition: daw_json_link_types_iso8601.h:31
#define DAW_JSON_VER
Definition: version.h:11