libscid snapshot+1833ab5ad39d
Chess applications made easy.
Source on GitHub License GPL v2
Loading...
Searching...
No Matches
date.h File Reference

Packed PGN/database date representation. More...

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdlib>
#include <stdint.h>
+ Include dependency graph for date.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  scid
 Public namespace for libscid.
 
namespace  scid::core
 Chess games, positions, movetext and notation.
 

Macros

#define DATE_MAKE(y, m, d)   (((y) << scid::core::YEAR_SHIFT) | ((m) << scid::core::MONTH_SHIFT) | (d))
 Builds a packed date from numeric year, month, and day fields.
 

Typedefs

typedef uint32_t scid::core::dateT
 Packed date value used by games, indexes, and statistics.
 

Functions

uint32_t scid::core::date_GetYear (dateT date)
 Returns the year field, or 0 when unknown.
 
uint32_t scid::core::date_GetMonth (dateT date)
 Returns the month field, or 0 when unknown.
 
uint32_t scid::core::date_GetDay (dateT date)
 Returns the day field, or 0 when unknown.
 
bool scid::core::date_isPartial (dateT date)
 Returns true when the year, month, or day field is unknown.
 
void scid::core::date_DecodeToString (dateT date, char *str)
 Writes a PGN date tag value into str.
 
dateT scid::core::date_EncodeFromString (const char *str)
 Parses a dotted date string into dateT.
 
dateT scid::core::date_parsePGNTag (const char *str, size_t len)
 Parses a PGN Date tag value.
 
dateT scid::core::date_parsePGNTag (std::pair< const char *, const char * > str)
 Parses a PGN Date tag value described by a pointer pair.
 

Variables

const dateT scid::core::ZERO_DATE = 0
 Unknown date.
 
const uint32_t scid::core::YEAR_SHIFT = 9
 Bit shift of the year field.
 
const uint32_t scid::core::MONTH_SHIFT = 5
 Bit shift of the month field.
 
const uint32_t scid::core::DAY_SHIFT = 0
 Bit shift of the day field.
 
const uint32_t scid::core::YEAR_MAX = 2047
 Maximum representable year.
 

Detailed Description

Packed PGN/database date representation.

Dates are stored in a 32-bit value as year, month, and day fields. Unknown fields are zero, so partial dates such as an unknown month or day can be represented while preserving chronological ordering for known fields.