source: ntrip/trunk/BNC/qwt/qwt_date.h@ 10411

Last change on this file since 10411 was 9383, checked in by stoecker, 4 years ago

update to qwt verion 6.1.1 to fix build with newer Qt5

File size: 3.4 KB
RevLine 
[8127]1/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
9
10#ifndef _QWT_DATE_H_
11#define _QWT_DATE_H_
12
13#include "qwt_global.h"
14#include <qdatetime.h>
15
16/*!
17 \brief A collection of methods around date/time values
18
19 Qt offers convenient classes for dealing with date/time values,
20 but Qwt uses coordinate systems that are based on doubles.
21 QwtDate offers methods to translate from QDateTime to double and v.v.
22
23 A double is interpreted as the number of milliseconds since
24 1970-01-01T00:00:00 Universal Coordinated Time - also known
[9383]25 as "The Epoch".
[8127]26
[9383]27 While the range of the Julian day in Qt4 is limited to [0, MAX_INT],
28 Qt5 stores it as qint64 offering a huge range of valid dates.
29 As the significance of a double is below this ( assuming a
30 fraction of 52 bits ) the translation is not
31 bijective with rounding errors for dates very far from Epoch.
32 For a resolution of 1 ms those start to happen for dates above the
33 year 144683.
[8127]34
35 An axis for a date/time interval is expected to be aligned
36 and divided in time/date units like seconds, minutes, ...
37 QwtDate offers several algorithms that are needed to
38 calculate these axes.
39
40 \sa QwtDateScaleEngine, QwtDateScaleDraw, QDate, QTime
41*/
42class QWT_EXPORT QwtDate
43{
44public:
[9383]45 /*!
[8127]46 How to identify the first week of year differs between
[9383]47 countries.
[8127]48 */
49 enum Week0Type
50 {
51 /*!
52 According to ISO 8601 the first week of a year is defined
53 as "the week with the year's first Thursday in it".
54
55 FirstThursday corresponds to the numbering that is
56 implemented in QDate::weekNumber().
57 */
58 FirstThursday,
59
60 /*!
61 "The week with January 1.1 in it."
[9383]62
[8127]63 In the U.S. this definition is more common than
64 FirstThursday.
65 */
66 FirstDay
67 };
68
[9383]69 /*!
[8127]70 Classification of an time interval
71
72 Time intervals needs to be classified to decide how to
73 align and divide it.
74 */
75 enum IntervalType
76 {
77 //! The interval is related to milliseconds
78 Millisecond,
79
80 //! The interval is related to seconds
81 Second,
82
83 //! The interval is related to minutes
84 Minute,
85
86 //! The interval is related to hours
87 Hour,
88
89 //! The interval is related to days
90 Day,
91
92 //! The interval is related to weeks
93 Week,
94
95 //! The interval is related to months
96 Month,
97
98 //! The interval is related to years
99 Year
100 };
101
102 enum
103 {
104 //! The Julian day of "The Epoch"
105 JulianDayForEpoch = 2440588
106 };
107
108 static QDate minDate();
109 static QDate maxDate();
110
[9383]111 static QDateTime toDateTime( double value,
[8127]112 Qt::TimeSpec = Qt::UTC );
113
114 static double toDouble( const QDateTime & );
115
116 static QDateTime ceil( const QDateTime &, IntervalType );
117 static QDateTime floor( const QDateTime &, IntervalType );
118
119 static QDate dateOfWeek0( int year, Week0Type );
120 static int weekNumber( const QDate &, Week0Type );
121
122 static int utcOffset( const QDateTime & );
123
[9383]124 static QString toString( const QDateTime &,
[8127]125 const QString & format, Week0Type );
126};
127
128#endif
Note: See TracBrowser for help on using the repository browser.