-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Merge pull request #677 from tiltedphoques/revert/calendarSync"
- Loading branch information
1 parent
4670a30
commit bdf281b
Showing
20 changed files
with
301 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "DateTime.h" | ||
#include <cmath> | ||
|
||
bool DateTime::operator==(const DateTime& other) const | ||
{ | ||
return m_timeModel == other.m_timeModel; | ||
} | ||
|
||
const uint32_t cDayLengthArray[12] = {31u, 28u, 31u, 30u, 31u, 30u, 31u, 31u, 30u, 31u, 30u, 31u}; | ||
|
||
uint32_t DateTime::GetNumberOfDaysByMonthIndex(int aIndex) | ||
{ | ||
return cDayLengthArray[aIndex % 12]; | ||
} | ||
|
||
void DateTime::Update(uint64_t aDeltaTick) | ||
{ | ||
m_timeModel.Time += GetDeltaTime(aDeltaTick); | ||
|
||
m_timeModel.Day += static_cast<uint32_t>(m_timeModel.Time / 24.f); | ||
m_timeModel.Time = std::fmod(m_timeModel.Time, 24.f); | ||
|
||
while (m_timeModel.Day > GetNumberOfDaysByMonthIndex(m_timeModel.Month)) | ||
{ | ||
m_timeModel.Day -= GetNumberOfDaysByMonthIndex(m_timeModel.Month); | ||
m_timeModel.Month++; | ||
} | ||
m_timeModel.Year += m_timeModel.Month / 12; | ||
m_timeModel.Month %= 12; | ||
} | ||
|
||
float DateTime::GetDeltaTime(uint64_t aDeltaTick) const noexcept | ||
{ | ||
float deltaSeconds = static_cast<float>(aDeltaTick) / 1000.f; | ||
return (deltaSeconds * (m_timeModel.TimeScale * 0.00027777778f)); | ||
} | ||
|
||
float DateTime::GetTimeInDays() const noexcept | ||
{ | ||
float totalDays = static_cast<float>(m_timeModel.Year) * 365.f; | ||
for (uint32_t i = 0u; i < m_timeModel.Month; i++) | ||
totalDays += GetNumberOfDaysByMonthIndex(i); | ||
totalDays += m_timeModel.Day; | ||
totalDays += (m_timeModel.Time / 24.f); | ||
return totalDays; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <encoding/Structs/TimeModel.h> | ||
|
||
struct DateTime | ||
{ | ||
[[nodiscard]] static uint32_t GetNumberOfDaysByMonthIndex(int index); | ||
|
||
DateTime() = default; | ||
DateTime(TimeModel aTimeModel) | ||
: m_timeModel(aTimeModel) | ||
{} | ||
|
||
bool operator==(const DateTime& other) const; | ||
void Update(uint64_t aDeltaTick); | ||
float GetDeltaTime(uint64_t aDeltaTick) const noexcept; | ||
float GetTimeInDays() const noexcept; | ||
|
||
TimeModel m_timeModel; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.