ASAP  1.0.0
A C++ header-only library for creating, displaying, iterating and manipulating dates
literals.h
1 /* * Copyright (C) 2018 Leonardo Guilherme Lucena de Freitas
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy of
4  * this software and associated documentation files (the "Software"), to deal in
5  * the Software without restriction, including without limitation the rights to
6  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7  * the Software, and to permit persons to whom the Software is furnished to do so,
8  * subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in all
11  * copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
21 #ifndef ASAP_LITERALS_H
22 #define ASAP_LITERALS_H
23 
24 #include "duration.h"
25 
26 namespace asap {
27  namespace literals {
28  inline static asap::years operator"" _years(long double v) { return asap::years(static_cast<double>(v)); }
29  inline static asap::year operator"" _year(long double v) { return asap::year(static_cast<double>(v)); }
30  inline static asap::years operator"" _yrs(long double v) { return asap::years(static_cast<double>(v)); }
31  inline static asap::years operator"" _Y(long double v) { return asap::years(static_cast<double>(v)); }
32  inline static asap::years operator"" _years(unsigned long long v) { return asap::years(static_cast<double>(v)); }
33  inline static asap::year operator"" _year(unsigned long long v) { return asap::year(static_cast<double>(v)); }
34  inline static asap::years operator"" _yrs(unsigned long long v) { return asap::years(static_cast<double>(v)); }
35  inline static asap::years operator"" _Y(unsigned long long v) { return asap::years(static_cast<double>(v)); }
36 
37  inline static asap::months operator"" _months(long double v) { return asap::months(static_cast<double>(v)); }
38  inline static asap::month operator"" _month(long double v) { return asap::month(static_cast<double>(v)); }
39  inline static asap::months operator"" _mon(long double v) { return asap::month(static_cast<double>(v)); }
40  inline static asap::months operator"" _m(long double v) { return asap::month(static_cast<double>(v)); }
41  inline static asap::months operator"" _months(unsigned long long v) { return asap::months(static_cast<double>(v)); }
42  inline static asap::month operator"" _month(unsigned long long v) { return asap::month(static_cast<double>(v)); }
43  inline static asap::months operator"" _mon(unsigned long long v) { return asap::month(static_cast<double>(v)); }
44  inline static asap::months operator"" _m(unsigned long long v) { return asap::month(static_cast<double>(v)); }
45 
46  inline static asap::days operator"" _days(long double v) { return asap::days(static_cast<double>(v)); }
47  inline static asap::day operator"" _day(long double v) { return asap::day(static_cast<double>(v)); }
48  inline static asap::days operator"" _d(long double v) { return asap::day(static_cast<double>(v)); }
49  inline static asap::days operator"" _days(unsigned long long v) { return asap::days(static_cast<double>(v)); }
50  inline static asap::day operator"" _day(unsigned long long v) { return asap::day(static_cast<double>(v)); }
51  inline static asap::days operator"" _d(unsigned long long v) { return asap::day(static_cast<double>(v)); }
52 
53  inline static asap::hours operator"" _hours(long double v) { return asap::hours(static_cast<double>(v)); }
54  inline static asap::hour operator"" _hour(long double v) { return asap::hour(static_cast<double>(v)); }
55  inline static asap::hours operator"" _hrs(long double v) { return asap::hours(static_cast<double>(v)); }
56  inline static asap::hours operator"" _H(long double v) { return asap::hours(static_cast<double>(v)); }
57  inline static asap::hours operator"" _hours(unsigned long long v) { return asap::hours(static_cast<double>(v)); }
58  inline static asap::hour operator"" _hour(unsigned long long v) { return asap::hour(static_cast<double>(v)); }
59  inline static asap::hours operator"" _hrs(unsigned long long v) { return asap::hours(static_cast<double>(v)); }
60  inline static asap::hours operator"" _H(unsigned long long v) { return asap::hours(static_cast<double>(v)); }
61 
62  inline static asap::minutes operator"" _minutes(long double v) { return asap::minutes(static_cast<double>(v)); }
63  inline static asap::minute operator"" _minute(long double v) { return asap::minute(static_cast<double>(v)); }
64  inline static asap::minute operator"" _min(long double v) { return asap::minute(static_cast<double>(v)); }
65  inline static asap::minutes operator"" _M(long double v) { return asap::minute(static_cast<double>(v)); }
66  inline static asap::minutes operator"" _minutes(unsigned long long v) { return asap::minutes(static_cast<double>(v)); }
67  inline static asap::minute operator"" _minute(unsigned long long v) { return asap::minute(static_cast<double>(v)); }
68  inline static asap::minute operator"" _min(unsigned long long v) { return asap::minute(static_cast<double>(v)); }
69  inline static asap::minutes operator"" _M(unsigned long long v) { return asap::minute(static_cast<double>(v)); }
70 
71  inline static asap::seconds operator"" _seconds(long double v) { return asap::seconds(static_cast<double>(v)); }
72  inline static asap::second operator"" _second(long double v) { return asap::second(static_cast<double>(v)); }
73  inline static asap::seconds operator"" _sec(long double v) { return asap::seconds(static_cast<double>(v)); }
74  inline static asap::seconds operator"" _S(long double v) { return asap::seconds(static_cast<double>(v)); }
75  inline static asap::seconds operator"" _seconds(unsigned long long v) { return asap::seconds(static_cast<double>(v)); }
76  inline static asap::second operator"" _second(unsigned long long v) { return asap::second(static_cast<double>(v)); }
77  inline static asap::seconds operator"" _sec(unsigned long long v) { return asap::seconds(static_cast<double>(v)); }
78  inline static asap::seconds operator"" _S(unsigned long long v) { return asap::seconds(static_cast<double>(v)); }
79  }
80 }
81 
82 #endif //ASAP_LITERALS_H
duration< SECONDS_IN_HOUR > hours
A duration specified in hours.
Definition: duration.h:49
duration< 1 > seconds
A duration specified in seconds.
Definition: duration.h:47
months month
A duration specified in months (30 days)
Definition: duration.h:52
duration< SECONDS_IN_MINUTE > minutes
A duration specified in minutes.
Definition: duration.h:48
seconds second
A duration specified in seconds.
Definition: duration.h:47
duration< SECONDS_IN_DAY > days
A duration specified in days.
Definition: duration.h:50
minutes minute
A duration specified in minutes.
Definition: duration.h:48
duration< SECONDS_IN_YEAR > years
A duration specified in years.
Definition: duration.h:53
duration< SECONDS_IN_MONTH > months
A duration specified in months (30 days)
Definition: duration.h:52
The asap::duration class exposes methods to create, manipulate and print durations.
Definition: duration.h:28
hours hour
A duration specified in hours.
Definition: duration.h:49
days day
A duration specified in days.
Definition: duration.h:50
Definition: asap.h:38
years year
A duration specified in years.
Definition: duration.h:53