herald
2.0.0
herald
include
herald
datatype
time_interval.h
1
// Copyright 2020-2021 Herald Project Contributors
2
// SPDX-License-Identifier: Apache-2.0
3
//
4
5
#ifndef HERALD_TIME_INTERVAL_H
6
#define HERALD_TIME_INTERVAL_H
7
8
#include "date.h"
9
10
#include <string>
11
#include <memory>
12
13
#include <cstdint>
14
#include <climits>
15
16
namespace
herald
{
17
namespace
datatype {
18
19
class
TimeInterval
{
20
public
:
21
static
TimeInterval
minutes(
long
minutes);
22
static
TimeInterval
seconds(
long
seconds);
23
static
TimeInterval
never();
24
static
TimeInterval
zero();
25
26
TimeInterval
(
long
seconds);
27
TimeInterval
(
const
Date
& date);
28
TimeInterval
(
const
Date
& from,
const
Date
& to);
29
TimeInterval
(
const
TimeInterval
& other);
// copy ctor
30
31
~
TimeInterval
();
32
33
TimeInterval
& operator=(
const
TimeInterval
& other) noexcept;
// copy assign
34
35
TimeInterval
operator*(
const
TimeInterval
& other) noexcept;
36
TimeInterval
operator+(
const
TimeInterval
& other) noexcept;
37
TimeInterval
& operator+=(
const
TimeInterval
& other) noexcept;
38
TimeInterval
operator-(
const
TimeInterval
& other) noexcept;
39
TimeInterval
& operator-=(
const
TimeInterval
& other) noexcept;
40
TimeInterval
operator*(
double
multiplier) noexcept;
41
TimeInterval
& operator*=(
double
multiplier) noexcept;
43
TimeInterval
operator/
(
double
divisor) noexcept;
45
TimeInterval
&
operator/=
(
double
divisor) noexcept;
46
47
bool
operator>(
const
TimeInterval
& other)
const
noexcept;
48
bool
operator>=(
const
TimeInterval
& other)
const
noexcept;
49
bool
operator<(
const
TimeInterval
& other)
const
noexcept;
50
bool
operator<=(
const
TimeInterval
& other)
const
noexcept;
51
bool
operator==(
const
TimeInterval
& other)
const
noexcept;
52
bool
operator!=(
const
TimeInterval
& other)
const
noexcept;
53
54
long
millis() const noexcept;
55
long
seconds() const noexcept;
56
57
operator
std
::
string
() const noexcept;
58
operator
long
() const noexcept;
// returns SECONDS not millis
59
60
private:
61
long
secs;
62
};
63
64
}
// end namespace
65
}
// end namespace
66
67
#endif
herald::datatype::Date
Definition:
date.h:18
herald::datatype::TimeInterval
Definition:
time_interval.h:19
herald::datatype::TimeInterval::operator/=
TimeInterval & operator/=(double divisor) noexcept
herald::datatype::TimeInterval::operator/
TimeInterval operator/(double divisor) noexcept
herald
Acts as a non-global memory arena for arbitrary classes.
Definition:
aggregates.h:15
std
Definition:
data.h:562
Generated by
1.9.1