ASAP  1.0.0
A C++ header-only library for creating, displaying, iterating and manipulating dates
asap.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_H
22 #define ASAP_H
23 
24 #include <ctime>
25 #include <string>
26 #include <iomanip>
27 #include <sstream>
28 #include <cmath>
29 #include <type_traits>
30 #include <cstdint>
31 
32 #include "datetime.h"
33 #include "duration.h"
34 #include "period.h"
35 #include "operators.h"
36 #include "literals.h"
37 
38 namespace asap {
39  static inline asap::datetime now() { return datetime{}; }
40 
41  static inline asap::datetime tomorrow() {
42  auto n = asap::now();
43  n += asap::days(1);
44  n.hour(0);
45  n.minute(0);
46  n.second(0);
47  return n;
48  }
49 
50  static inline asap::datetime yesterday() {
51  auto n = asap::now();
52  n -= asap::days(1);
53  n.hour(0);
54  n.minute(0);
55  n.second(0);
56  return n;
57  }
58 }
59 
60 #include "datetime.tcc"
61 #include "duration.tcc"
62 #include "period.tcc"
63 
64 #endif //ASAP_H
static asap::datetime tomorrow()
Creates an asap::datetime instance representing the next day at 00:00:00.
Definition: asap.h:41
static asap::datetime yesterday()
Creates an asap::datetime instance representing the previous day at 00:00:00.
Definition: asap.h:50
duration< SECONDS_IN_DAY > days
A duration specified in days.
Definition: duration.h:50
The asap::datetime class exposes methods to create, manipulate and print dates.
Definition: datetime.h:29
Definition: asap.h:38
static asap::datetime now()
Creates an asap::datetime instance representing current time.
Definition: asap.h:39