45 #define DATE_MAKE(y,m,d) (((y) << YEAR_SHIFT) | ((m) << MONTH_SHIFT) | (d)) 72 return (
uint) (date & 31);
81 return (
uint) (date & 511);
90 uint year, month, day;
97 *str++ =
'?'; *str++ =
'?'; *str++ =
'?'; *str++ =
'?';
99 *str++ =
'0' + (year / 1000);
100 *str++ =
'0' + (year % 1000) / 100;
101 *str++ =
'0' + (year % 100) / 10;
102 *str++ =
'0' + (year % 10);
107 *str++ =
'?'; *str++ =
'?';
109 *str++ =
'0' + (month / 10);
110 *str++ =
'0' + (month % 10);
115 *str++ =
'?'; *str++ =
'?';
117 *str++ =
'0' + (day / 10);
118 *str++ =
'0' + (day % 10);
133 uint year, month, day;
136 year = std::strtoul(str, NULL, 10);
139 while (*str != 0 && *str !=
'.') { str++; }
140 if (*str ==
'.') { str++; }
143 month = std::strtoul(str, NULL, 10);
144 if (month > 12) {
return date; }
146 while (*str != 0 && *str !=
'.') { str++; }
147 if (*str ==
'.') { str++; }
150 day = std::strtoul(str, NULL, 10);
151 if (day > 31) {
return date; }
168 std::transform(str, str + std::min<size_t>(len, 10), tmp, [](
char ch) {
169 return (ch >=
'0' && ch <=
'9') ? ch -
'0' : 0;
172 uint32_t year = tmp[0] * 1000 + tmp[1] * 100 + tmp[2] * 10 + tmp[3];
173 uint32_t month = tmp[5] * 10 + tmp[6];
174 uint32_t day = tmp[8] * 10 + tmp[9];
182 constexpr
unsigned char days[] = {31, 31, 28, 31, 30, 31, 30,
183 31, 31, 30, 31, 30, 31};
184 if (day > days[month]) {
185 if (day != 29 || year % 4 || (year % 100 == 0 && year % 400)) {
197 #endif // #ifndef SCID_DATE_H uint date_GetYear(dateT date)
dateT date_parsePGNTag(const char *str, size_t len)
Creates a dateT object from a PGN tag value string.
void date_DecodeToString(dateT date, char *str)
uint date_GetMonthDay(dateT date)
uint date_GetMonth(dateT date)
dateT date_EncodeFromString(const char *str)
uint date_GetDay(dateT date)