A collection of methods around date/time values. More...
#include <qwt_date.h>
Public Types | |
enum | { JulianDayForEpoch = 2440588 } |
enum | IntervalType { Millisecond, Second, Minute, Hour, Day, Week, Month, Year } |
enum | Week0Type { FirstThursday, FirstDay } |
Static Public Member Functions | |
static QDateTime | ceil (const QDateTime &, IntervalType) |
static QDate | dateOfWeek0 (int year, Week0Type) |
Date of the first day of the first week for a year. More... | |
static QDateTime | floor (const QDateTime &, IntervalType) |
static QDate | maxDate () |
static QDate | minDate () |
static QDateTime | toDateTime (double value, Qt::TimeSpec=Qt::UTC) |
static double | toDouble (const QDateTime &) |
static QString | toString (const QDateTime &, const QString &format, Week0Type) |
static int | utcOffset (const QDateTime &) |
static int | weekNumber (const QDate &, Week0Type) |
A collection of methods around date/time values.
Qt offers convenient classes for dealing with date/time values, but Qwt uses coordinate systems that are based on doubles. QwtDate offers methods to translate from QDateTime to double and v.v.
A double is interpreted as the number of milliseconds since 1970-01-01T00:00:00 Universal Coordinated Time - also known as "The Epoch".
While the range of the Julian day in Qt4 is limited to [0, MAX_INT], Qt5 stores it as qint64 offering a huge range of valid dates. As the significance of a double is below this ( assuming a fraction of 52 bits ) the translation is not bijective with rounding errors for dates very far from Epoch. For a resolution of 1 ms those start to happen for dates above the year 144683.
An axis for a date/time interval is expected to be aligned and divided in time/date units like seconds, minutes, ... QwtDate offers several algorithms that are needed to calculate these axes.
Definition at line 42 of file qwt_date.h.
anonymous enum |
Enumerator | |
---|---|
JulianDayForEpoch | The Julian day of "The Epoch". |
Definition at line 109 of file qwt_date.h.
Classification of an time interval
Time intervals needs to be classified to decide how to align and divide it.
Definition at line 82 of file qwt_date.h.
enum QwtDate::Week0Type |
How to identify the first week of year differs between countries.
Definition at line 56 of file qwt_date.h.
|
static |
Ceil a datetime according the interval type
dateTime | Datetime value |
intervalType | Interval type, how to ceil. F.e. when intervalType = QwtDate::Months, the result will be ceiled to the next beginning of a month |
Definition at line 323 of file qwt_date.cpp.
|
static |
Date of the first day of the first week for a year.
The first day of a week depends on the current locale ( QLocale::firstDayOfWeek() ).
year | Year |
type | Option how to identify the first week |
Definition at line 542 of file qwt_date.cpp.
|
static |
Floor a datetime according the interval type
dateTime | Datetime value |
intervalType | Interval type, how to ceil. F.e. when intervalType = QwtDate::Months, the result will be ceiled to the next beginning of a month |
Definition at line 425 of file qwt_date.cpp.
|
static |
Maximum for the supported date range
The range of valid dates depends on how QDate stores the Julian day internally.
Definition at line 521 of file qwt_date.cpp.
|
static |
Minimum for the supported date range
The range of valid dates depends on how QDate stores the Julian day internally.
Definition at line 499 of file qwt_date.cpp.
|
static |
Translate from double to QDateTime
value | Number of milliseconds since the epoch, 1970-01-01T00:00:00 UTC |
timeSpec | Time specification |
Definition at line 261 of file qwt_date.cpp.
|
static |
Translate from QDateTime to double
dateTime | Datetime value |
Definition at line 298 of file qwt_date.cpp.
|
static |
Translate a datetime into a string
Beside the format expressions documented in QDateTime::toString() the following expressions are supported:
As week 1 usually starts in the previous year a special rule is applied for formats, where the year is expected to match the week number - even if the date belongs to the previous year.
dateTime | Datetime value |
format | Format string |
week0Type | Specification of week 0 |
Definition at line 686 of file qwt_date.cpp.
|
static |
Offset in seconds from Coordinated Universal Time
The offset depends on the time specification of dateTime:
For Qt::LocalTime the offset depends on the timezone and daylight savings.
dateTime | Datetime value |
Definition at line 635 of file qwt_date.cpp.
|
static |
Find the week number of a date
date | Date |
type | Option how to identify the first week |
Definition at line 585 of file qwt_date.cpp.