MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
calendars/mtcore_calendars/traits.hpp
Go to the documentation of this file.
1/*
2
3Copyright 2025 Matthew Tolman
4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16
17*/
18
19#ifndef MTCORE_CALENDARS_TRAITS_HPP
20#define MTCORE_CALENDARS_TRAITS_HPP
21
22namespace mtcore::calendars {
23 struct Fixed;
24 struct Moment;
25 struct UnixTimestamp;
26
27 template<typename T>
28 concept IsDayCalendarSystem = requires(const T &t, const Fixed &f) {
29 { t.to_fixed() } -> std::same_as<Fixed>;
30 { T::from_fixed(f) } -> std::same_as<T>;
31 { T::EPOCH };
32 { T::name };
33 { t <=> t } -> std::same_as<std::strong_ordering>;
34 };
35
36 template<typename T>
37 concept IsTimeCalendarSystem = requires(const T &t, const Moment &f) {
38 { t.to_moment() } -> std::same_as<Moment>;
39 { T::from_moment(f) } -> std::same_as<T>;
40 { T::EPOCH };
41 { T::name };
42 { t <=> t } -> std::same_as<std::partial_ordering>;
43 };
44} // namespace mtcore::calendars
45
46#endif // MTCORE_CALENDARS_TRAITS_HPP
Namespace for calendaring systems.
Base calendar system tracking the number of days since its epoch.
Definition fixed.hpp:42
Base calendar system tracking the number of days (and fraction of days) since its epoch.
Definition fixed.hpp:264