• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

Public Member Functions | List of all members
TimeZoneRule Class Reference

#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 ()
 
KStarsDateTime nextDSTChange ()
 
KStarsDateTime nextDSTChange_LTime ()
 
void reset_with_ltime (KStarsDateTime &ltime, 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 attachded to each city in Cities.dat.

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.

Author
Jason Harris
Version
1.0

Definition at line 56 of file timezonerule.h.

Constructor & Destructor Documentation

TimeZoneRule::TimeZoneRule ( )

Default Constructor.

Makes the "empty" time zone rule (i.e., no DST correction)

Definition at line 25 of file timezonerule.cpp.

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
smonththe three-letter code for the month in which DST starts
sdaya string encoding the day on which DST starts (see the class description)
stimethe time at which DST starts
rmonththe three-letter code for the month in which DST reverts
rdaya string encoding the day on which DST reverts (see the class description)
rtimethe time at which DST reverts
offsetthe offset between normal time and DS time (always 1.00?)

Definition at line 29 of file timezonerule.cpp.

Member Function Documentation

double TimeZoneRule::deltaTZ ( ) const
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 88 of file timezonerule.h.

bool TimeZoneRule::equals ( TimeZoneRule *  r)
Returns
true if this rule is the same as the argument.
Parameters
rthe rule to check for equivalence

Definition at line 406 of file timezonerule.cpp.

bool TimeZoneRule::isDSTActive ( const KStarsDateTime &  date)

Determine whether DST is in effect for the given DateTime, according to this rule.

Parameters
datethe date/time to test for DST

Definition at line 179 of file timezonerule.cpp.

bool TimeZoneRule::isEmptyRule ( )
inline
Returns
true if the rule is the "empty" TZ rule.

Definition at line 79 of file timezonerule.h.

KStarsDateTime TimeZoneRule::nextDSTChange ( )
inline
Returns
computed value for next DST change in universal time.

Definition at line 103 of file timezonerule.h.

KStarsDateTime TimeZoneRule::nextDSTChange_LTime ( )
inline
Returns
computed value for next DST change in local time.

Definition at line 106 of file timezonerule.h.

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
ltimethe time to be tested
time_runs_forwardtime direction
TZoffsetoffset of timezone in some fictional unit
automaticDSTchangeis automatic DST change?
Todo:
Check dox for TZoffset

There are some problems using local time for getting next daylight saving change time.

  1. The local time is the start time of DST change. So the local time doesn't exists and must corrected.
  2. The local time is the revert time. So the local time exists twice.
  3. 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 301 of file timezonerule.cpp.

void TimeZoneRule::setDST ( bool  activate = true)

Toggle DST on/off.

The activate argument should probably be isDSTActive()

Parameters
activateif true, then set DST active; otherwise, deactivate DST

Definition at line 63 of file timezonerule.cpp.


The documentation for this class was generated from the following files:
  • timezonerule.h
  • timezonerule.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:23 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal