TimeZoneRule
#include <timezonerule.h>
Public Member Functions | |
TimeZoneRule () | |
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) |
Detailed Description
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.
- Version
- 1.0
Definition at line 47 of file timezonerule.h.
Constructor & Destructor Documentation
◆ TimeZoneRule() [1/2]
TimeZoneRule::TimeZoneRule | ( | ) |
Default Constructor.
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 = 1.00 ) |
Constructor.
Create a TZ rule according to the arguments.
- Parameters
-
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
◆ deltaTZ()
|
inline |
- Returns
- 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.
◆ equals()
bool TimeZoneRule::equals | ( | TimeZoneRule * | r | ) |
- Returns
- true if this rule is the same as the argument.
- Parameters
-
r the rule to check for equivalence
Definition at line 557 of file timezonerule.cpp.
◆ isDSTActive()
bool TimeZoneRule::isDSTActive | ( | const KStarsDateTime & | date | ) |
Determine whether DST is in effect for the given DateTime, according to this rule.
- Parameters
-
date the date/time to test for DST
Definition at line 283 of file timezonerule.cpp.
◆ isEmptyRule()
|
inline |
- Returns
- true if the rule is the "empty" TZ rule.
Definition at line 71 of file timezonerule.h.
◆ nextDSTChange()
|
inline |
- Returns
- computed value for next DST change in universal time.
Definition at line 95 of file timezonerule.h.
◆ nextDSTChange_LTime()
|
inline |
- Returns
- computed value for next DST change in local time.
Definition at line 98 of file timezonerule.h.
◆ reset_with_ltime()
void TimeZoneRule::reset_with_ltime | ( | KStarsDateTime & | ltime, |
const double | TZoffset, | ||
const bool | time_runs_forward, | ||
const bool | automaticDSTchange = false ) |
Recalculate next dst change and if DST is active by a given local time with timezone offset and time direction.
- Parameters
-
ltime the time to be tested time_runs_forward time direction TZoffset offset of timezone in some fictional unit automaticDSTchange is automatic DST change?
- Todo
- 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.
◆ setDST()
void TimeZoneRule::setDST | ( | bool | activate = true | ) |
Toggle DST on/off.
The activate
argument should probably be isDSTActive()
- Parameters
-
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-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.