Conquer Space 0.0.0
A space themed grand strategy game set in the near future, with realistic orbital mechanics, and an emphasis on economics and politics.
stardate.h
Go to the documentation of this file.
1/* Conquer Space
2 * Copyright (C) 2021-2025 Conquer Space
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <cstdint>
20#include <string>
21
22namespace cqsp::core::components {
46class StarDate {
47 public:
48 // How many seconds a tick is
49 static const int TIME_INCREMENT = 60;
50
51 static const int MINUTE = 1;
52 static const int HOUR = 60 * MINUTE;
53 static const int DAY = 24 * HOUR;
54 static const int WEEK = DAY * 7;
55
56 static const int YEAR = DAY * 365;
57
58 void IncrementDate() { date++; }
59
60 uint64_t GetDate() { return date; }
61
62 double ToSecond() { return (double)date * TIME_INCREMENT; }
63 double ToDay() { return date / (float)DAY; }
64
65 std::string ToString();
66 std::string ToString(double offset);
67
68 int GetYear();
69 int GetMonth();
70 int GetDay();
71 int GetHour(double offset = 0.0);
72 int GetMinute();
73
74 void SetDate(unsigned int _date) { date = _date; }
75
76 double operator()() { return ToSecond(); }
77
78 private:
79 // Time in minutes since the start date
80 // This value is set to -1 since we will need to 0th tick to initialize everything properly
81 uint64_t date = -1;
82
83 static const int start_date = 2000;
84};
85} // namespace cqsp::core::components
Holds and calculates the tick that is on going. Date is the number of hours that has been ongoing sin...
Definition: stardate.h:46
int GetDay()
Definition: stardate.cpp:63
static const int TIME_INCREMENT
Definition: stardate.h:49
int GetHour(double offset=0.0)
Definition: stardate.cpp:71
double ToSecond()
Definition: stardate.h:62
void IncrementDate()
Definition: stardate.h:58
void SetDate(unsigned int _date)
Definition: stardate.h:74
uint64_t date
Definition: stardate.h:81
int GetYear()
Definition: stardate.cpp:53
static const int MINUTE
Definition: stardate.h:51
static const int HOUR
Definition: stardate.h:52
static const int WEEK
Definition: stardate.h:54
int GetMinute()
Definition: stardate.cpp:72
static const int DAY
Definition: stardate.h:53
static const int YEAR
Definition: stardate.h:56
int GetMonth()
Definition: stardate.cpp:58
uint64_t GetDate()
Definition: stardate.h:60
static const int start_date
Definition: stardate.h:83
std::string ToString()
Definition: stardate.cpp:33
double ToDay()
Definition: stardate.h:63
double operator()()
Definition: stardate.h:76
Definition: area.h:23