Public Member Functions
|TimeZoneRule (const QString &smonth, const QString &sday, const QTime &stime, const QString &rmonth, const QString &rday, const QTime &rtime, const double &offset=1.00)|
|double||deltaTZ () const|
|bool||equals (TimeZoneRule *r)|
|bool||isDSTActive (const KStarsDateTime &date)|
|bool||isEmptyRule () const|
|KStarsDateTime||nextDSTChange () const|
|KStarsDateTime||nextDSTChange_LTime () const|
|void||reset_with_ltime (KStarsDateTime <ime, const double TZoffset, const bool time_runs_forward, const bool automaticDSTchange=false)|
|void||setDST (bool activate=true)|
This class provides the information needed to determine whether Daylight Savings Time (DST; a.k.a. "Summer Time") is currently active at a given location. There are (at least) 25 different "rules" which govern DST around the world; a string identifying the appropriate rule is attached to each city in citydb.sqlite.
The rules themselves are stored in the TZrulebook.dat file, which is read on startup; each line in the file creates a TimeZoneRule object.
TimeZoneRule consists of QStrings identifying the months and days on which DST starts and ends, QTime objects identifying the time at which the changes occur, and a double indicating the size of the offset in hours (probably always 1.00).
Month names should be the English three-letter abbreviation, uncapitalized. Day names are either an integer indicating the calendar date (i.e., "15" is the fifteenth of the month), or a number paired with a three-letter abbreviation for a weekday. This indicates the Nth weekday of the month (i.e., "2sun" is the second Sunday of the Month). Finally, the weekday string on its own indicates the last weekday of the month (i.e., "mon" is the last Monday of the month).
The isDSTActive(KStarsDateTime) function returns true if DST is active for the DateTime given as an argument.
The nextDSTChange(KStarsDateTime) function returns the KStarsDateTime of the moment at which the next DST change will occur for the current location.
Definition at line 47 of file timezonerule.h.
Constructor & Destructor Documentation
◆ TimeZoneRule() [1/2]
Makes the "empty" time zone rule (i.e., no DST correction)
Definition at line 14 of file timezonerule.cpp.
◆ TimeZoneRule() [2/2]
|TimeZoneRule::TimeZoneRule||(||const QString &||smonth,|
|const QString &||sday,|
|const QTime &||stime,|
|const QString &||rmonth,|
|const QString &||rday,|
|const QTime &||rtime,|
|const double &||offset =
Create a TZ rule according to the arguments.
smonth the three-letter code for the month in which DST starts sday a string encoding the day on which DST starts (see the class description) stime the time at which DST starts rmonth the three-letter code for the month in which DST reverts rday a string encoding the day on which DST reverts (see the class description) rtime the time at which DST reverts offset the offset between normal time and DS time (always 1.00?)
Definition at line 19 of file timezonerule.cpp.
Member Function Documentation
- the current Timezone offset, compared to the timezone's Standard Time. This is typically 0.0 if DST is inactive, and 1.0 if DST is active.
Definition at line 80 of file timezonerule.h.
|bool TimeZoneRule::equals||(||TimeZoneRule *||r||)|
- true if this rule is the same as the argument.
r the rule to check for equivalence
Definition at line 557 of file timezonerule.cpp.
|bool TimeZoneRule::isDSTActive||(||const KStarsDateTime &||date||)|
Determine whether DST is in effect for the given DateTime, according to this rule.
date the date/time to test for DST
Definition at line 283 of file timezonerule.cpp.
- true if the rule is the "empty" TZ rule.
Definition at line 71 of file timezonerule.h.
- computed value for next DST change in universal time.
Definition at line 95 of file timezonerule.h.
- computed value for next DST change in local time.
Definition at line 98 of file timezonerule.h.
|void TimeZoneRule::reset_with_ltime||(||KStarsDateTime &||ltime,|
|const bool||automaticDSTchange =
Recalculate next dst change and if DST is active by a given local time with timezone offset and time direction.
ltime the time to be tested time_runs_forward time direction TZoffset offset of timezone in some fictional unit automaticDSTchange is automatic DST change?
- Check dox for TZoffset
There are some problems using local time for getting next daylight saving change time.
- The local time is the start time of DST change. So the local time doesn't exists and must corrected.
- The local time is the revert time. So the local time exists twice.
- Neither start time nor revert time. There is no problem.
Problem #1 is more complicated and we have to change the local time by reference. Problem #2 we just have to reset status of DST.
automaticDSTchange should only set to true if DST status changed due to running automatically over a DST change time. If local time will changed manually the automaticDSTchange should always set to false, to hold current DST status if possible (just on start and revert time possible).
Definition at line 432 of file timezonerule.cpp.
|void TimeZoneRule::setDST||(||bool||activate = ||)|
Toggle DST on/off.
activate argument should probably be isDSTActive()
activate if true, then set DST active; otherwise, deactivate DST
Definition at line 61 of file timezonerule.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:57:39 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.