summaryrefslogtreecommitdiffhomepage
path: root/Timeline.cpp
blob: b6003e506943b4b705e7c7435984ad5284aa6984 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "Timeline.h"

#include <algorithm>
#include <ctime>


Timeline::Timeline(const std::time_t start, const std::time_t end) :
    m_start {start},
    m_end {static_cast<double>(end - start)},
    m_current {0.0}
{
}


std::time_t
Timeline::timestamp() const
{
    return m_start + m_current;
}


double
Timeline::current() const
{
    return m_current;
}


double
Timeline::progress() const
{
    return m_current / m_end;
}


double
Timeline::move(const double dt)
{
    return m_current = std::clamp(m_current + dt, 0.0, m_end);
}