EHM DAL 0.2.5
Data abstraction layer for Eastside Hockey Manager
Loading...
Searching...
No Matches
date.h
1#pragma once
2
3// Application headers
4#include "include/data_types/private/abstract_data_type.h"
5
6// Qt headers
7class QDataStream;
8#include <QDate>
9
10namespace ehm_dal::data_types {
11
12// --- SI_Date wrapper --- //
16class Date : public AbstractDataType
17{
18public:
23
24 // File i/o
29 void readFromSavedGame(QDataStream &in);
30
31 // Get data
36 inline QDate get() const { return date_; }
44 void toSiDate(qint16 &day, qint16 &year, bool &is_leap_year) const; // Must pass by reference
48 inline qint32 year() const { return date_.year(); }
49
50 // Set data
56 void set(qint16 day, qint16 year);
57
58 // Thresholds
63 MINIMUM_YEAR = 1900,
66 };
67
68private:
69 QDate date_{1900, 2, 1};
70
71 // File i/o
72 friend QDataStream &operator>>(QDataStream &in, Date &data);
73 friend QDataStream &operator<<(QDataStream &out, const Date &data);
74
75 // Get data
80 inline QVariant value(const qint32 role = Qt::DisplayRole) const override
81 {
82 Q_UNUSED(role)
83 return date_;
84 }
85
86 // Set data
87 void setValue(const QVariant &value) override;
88};
89
90// File i/o
91QDataStream &operator>>(QDataStream &in, Date &data);
92QDataStream &operator<<(QDataStream &out, const Date &data);
93
94} // namespace ehm_dal::data_types
95
96
The AbstractDataType class provides common virtual functions for all integral game data types.
Definition: abstract_data_type.h:11
QVariant data(const qint32 role=Qt::DisplayRole) const
Returns the data stored under the given role for the item.
The Date class acts as a QDate wrapper for EHM format SI_Date.
Definition: date.h:17
QDate get() const
Returns the date.
Definition: date.h:36
void set(qint16 day, qint16 year)
Sets the Date from an SI_Date format date.
ENUM_THRESHOLDS
The ENUM_THRESHOLDS enum denotes certain date thresholds.
Definition: date.h:62
@ FIRST_DAY_OF_THE_YEAR
Definition: date.h:65
@ FEBRUARY_28TH
Definition: date.h:64
@ MINIMUM_YEAR
Definition: date.h:63
Date()
Default constructor.
qint32 year() const
Returns the year.
Definition: date.h:48
void toSiDate(qint16 &day, qint16 &year, bool &is_leap_year) const
Converts the Date to SI_Date format. The day, year and is_leap_year must be passed by reference....
void readFromSavedGame(QDataStream &in)
Reads an SI_Date from a saved game which does not include a bool leap year value.
namespace ehm_dal::data_types
Definition: attribute.h:6