QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
Public 类型 | 静态 Public 成员函数 | 所有成员列表
QwtDate类 参考

A collection of methods around date/time values 更多...

#include <qwt_date.h>

Public 类型

enum  Week0Type { FirstThursday , FirstDay }
 How to identify the first week of year differs between countries 更多...
 
enum  IntervalType {
  Millisecond , Second , Minute , Hour ,
  Day , Week , Month , Year
}
 Classification of a time interval 更多...
 
enum  { JulianDayForEpoch = 2440588 }
 

静态 Public 成员函数

static QDate minDate ()
 Minimum for the supported date range
 
static QDate maxDate ()
 Maximum for the supported date range
 
static QTimeZone toTimeZone (Qt::TimeSpec timeSpec, int offsetSeconds=0)
 Convert a Qt::TimeSpec to a QTimeZone
 
static QDateTime toDateTime (double value, Qt::TimeSpec=Qt::UTC)
 Translate from double to QDateTime
 
static QDateTime toDateTime (double value, const QTimeZone &timeZone)
 Translate from double to QDateTime
 
static double toDouble (const QDateTime &)
 Translate from QDateTime to double
 
static QDateTime ceil (const QDateTime &, IntervalType)
 Ceil a datetime according the interval type
 
static QDateTime floor (const QDateTime &, IntervalType)
 Floor a datetime according the interval type
 
static QDate dateOfWeek0 (int year, Week0Type)
 Date of the first day of the first week for a year
 
static int weekNumber (const QDate &, Week0Type)
 Find the week number of a date
 
static int utcOffset (const QDateTime &)
 Offset in seconds from Coordinated Universal Time
 
static QString toString (const QDateTime &, const QString &format, Week0Type)
 Translate a datetime into a string
 

详细描述

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.

参见
QwtDateScaleEngine, QwtDateScaleDraw, QDate, QTime

成员枚举类型说明

◆ anonymous enum

anonymous enum
枚举值
JulianDayForEpoch 

The Julian day of "The Epoch"

◆ IntervalType

Classification of a time interval

Time intervals need to be classified to decide how to align and divide it.

枚举值
Millisecond 

Millisecond

Second 

Second

Minute 

Minute

Hour 

Hour

Day 

Day

Week 

Week

Month 

Month

Year 

Year

◆ Week0Type

How to identify the first week of year differs between countries

枚举值
FirstThursday 

According to ISO 8601 the first week of a year is defined as "the week with the year's first Thursday in it". FirstThursday corresponds to the numbering that is implemented in QDate::weekNumber().

FirstDay 

"The week with January 1 in it." In the U.S. this definition is more common than FirstThursday.

成员函数说明

◆ ceil()

QDateTime QwtDate::ceil ( const QDateTime &  dateTime,
IntervalType  intervalType 
)
static

Ceil a datetime according the interval type

参数
dateTimeDatetime value
intervalTypeInterval type, how to ceil. F.e. when intervalType = QwtDate::Months, the result will be ceiled to the next beginning of a month
返回
Ceiled datetime
参见
floor()

◆ dateOfWeek0()

QDate QwtDate::dateOfWeek0 ( int  year,
Week0Type  type 
)
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() ).

参数
yearYear
typeOption how to identify the first week
返回
First day of week 0
参见
QLocale::firstDayOfWeek(), weekNumber()

◆ floor()

QDateTime QwtDate::floor ( const QDateTime &  dateTime,
IntervalType  intervalType 
)
static

Floor a datetime according the interval type

参数
dateTimeDatetime value
intervalTypeInterval type, how to floor. F.e. when intervalType = QwtDate::Months, the result will be floored to the beginning of a month
返回
Floored datetime
参见
ceil()

◆ maxDate()

QDate QwtDate::maxDate ( )
static

Maximum for the supported date range

The range of valid dates depends on how QDate stores the Julian day internally.

  • For Qt4 it is "Tue Jun 3 5874898"
  • For Qt5 it is "Tue Dec 31 2147483647"
返回
maximum of the date range
参见
minDate()
注解
The maximum differs between Qt4 and Qt5

◆ minDate()

QDate QwtDate::minDate ( )
static

Minimum for the supported date range

The range of valid dates depends on how QDate stores the Julian day internally.

  • For Qt4 it is "Tue Jan 2 -4713"
  • For Qt5 it is "Thu Jan 1 -2147483648"
返回
minimum of the date range
参见
maxDate()

◆ toDateTime() [1/2]

QDateTime QwtDate::toDateTime ( double  value,
const QTimeZone &  timeZone 
)
static

Translate from double to QDateTime

参数
valueNumber of milliseconds since the epoch, 1970-01-01T00:00:00 UTC
timeZoneTime zone
返回
Datetime value
参见
toDouble(), QwtDate::toDateTime(double, Qt::TimeSpec)

◆ toDateTime() [2/2]

QDateTime QwtDate::toDateTime ( double  value,
Qt::TimeSpec  timeSpec = Qt::UTC 
)
static

Translate from double to QDateTime

参数
valueNumber of milliseconds since the epoch, 1970-01-01T00:00:00 UTC
timeSpecTime specification
返回
Datetime value
参见
toDouble(), QDateTime::setMSecsSinceEpoch()
注解
The return datetime for Qt::OffsetFromUTC will be Qt::UTC

◆ toDouble()

double QwtDate::toDouble ( const QDateTime &  dateTime)
static

Translate from QDateTime to double

参数
dateTimeDatetime value
返回
Number of milliseconds since 1970-01-01T00:00:00 UTC has passed.
参见
toDateTime(), QDateTime::toMSecsSinceEpoch()
警告
For values very far below or above 1970-01-01 UTC rounding errors will happen due to the limited significance of a double.

◆ toString()

QString QwtDate::toString ( const QDateTime &  dateTime,
const QString &  format,
Week0Type  week0Type 
)
static

Translate a datetime into a string

Beside the format expressions documented in QDateTime::toString() the following expressions are supported:

  • w: week number ( 1 - 53 )
  • ww: week number with a leading zero ( 01 - 53 )

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.

参数
dateTimeDatetime value
formatFormat string
week0TypeSpecification of week 0
返回
Datetime string
参见
QDateTime::toString(), weekNumber(), QwtDateScaleDraw

◆ toTimeZone()

QTimeZone QwtDate::toTimeZone ( Qt::TimeSpec  timeSpec,
int  offsetSeconds = 0 
)
static

Convert a Qt::TimeSpec to a QTimeZone

参数
timeSpecTime specification
offsetSecondsOffset in seconds (used for Qt::OffsetFromUTC)
返回
QTimeZone corresponding to the time specification

◆ utcOffset()

int QwtDate::utcOffset ( const QDateTime &  dateTime)
static

Offset in seconds from Coordinated Universal Time

The offset depends on the time specification of dateTime:

  • Qt::UTC: 0, dateTime has no offset
  • Qt::OffsetFromUTC: returns dateTime.offsetFromUtc()
  • Qt::LocalTime: number of seconds from the UTC

For Qt::LocalTime the offset depends on the timezone and daylight savings.

参数
dateTimeDatetime value
返回
Offset in seconds

◆ weekNumber()

int QwtDate::weekNumber ( const QDate &  date,
Week0Type  type 
)
static

Find the week number of a date

参数
dateDate
typeOption how to identify the first week
返回
Week number, starting with 1

该类的文档由以下文件生成: