Zcalanie ręczne. Jak git nie chce po dobroci to będzie siłą
This commit is contained in:
parent
690e5278c5
commit
3bf98ba472
22 changed files with 790 additions and 457 deletions
47
TimeStamp.h
Normal file
47
TimeStamp.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
|
||||
class TimeStamp
|
||||
{
|
||||
public:
|
||||
TimeStamp()
|
||||
:time(std::time(nullptr))
|
||||
{}
|
||||
~TimeStamp() = default;
|
||||
|
||||
uint32_t get()
|
||||
{
|
||||
#if defined(_WIN32) localtime_s(<, &time);
|
||||
#else localtime_r(<, &time);
|
||||
#endif
|
||||
|
||||
uint16_t d = dosDate(lt);
|
||||
uint16_t t = dosTime(lt);
|
||||
|
||||
uint32_t combined = ((uint32_t)d << 16) | t;
|
||||
return combined;
|
||||
}
|
||||
|
||||
private:
|
||||
std::time_t time;
|
||||
std::tm lt{};
|
||||
|
||||
uint16_t dosDate(const std::tm& t)
|
||||
{
|
||||
int year = t.tm_year + 1900;
|
||||
int y = (year >= 1980) ? (year - 1980) : 0;
|
||||
int m = t.tm_mon + 1;
|
||||
int d = t.tm_mday;
|
||||
return static_cast<uint16_t>((y << 9) | (m << 5) | d);
|
||||
}
|
||||
|
||||
uint16_t dosTime(const std::tm& t)
|
||||
{
|
||||
int h = t.tm_hour;
|
||||
int min = t.tm_min;
|
||||
int s2 = t.tm_sec / 2;
|
||||
return static_cast<uint16_t>((h << 11) | (min << 5) | s2);
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue