LocalTimeRK
Public Member Functions | Data Fields
LocalTimeChange Class Reference

Handles the time change part of the Posix timezone string like "M3.2.0/2:00:00". More...

#include <LocalTimeRK.h>

Public Member Functions

 LocalTimeChange ()
 Default contructor.
 
virtual ~LocalTimeChange ()
 Destructor.
 
 LocalTimeChange (const char *str)
 Constructs a time change object with a string format (calls parse()) More...
 
void clear ()
 Clears all values.
 
void parse (const char *str)
 Parses a time change string. More...
 
String toString () const
 Turns the parsed data into a normalized string like "M3.2.0/2:00:00".
 
time_t calculate (struct tm *pTimeInfo, LocalTimeHMS tzAdjust) const
 Calculate the time change in a given year. More...
 

Data Fields

int8_t month = 0
 1-12, 1=January
 
int8_t week = 0
 1-5, 1=first
 
int8_t dayOfWeek = 0
 0-6, 0=Sunday, 1=Monday, ...
 
int8_t valid = 0
 true = valid
 
LocalTimeHMS hms
 Local time when timezone change occurs.
 

Detailed Description

Handles the time change part of the Posix timezone string like "M3.2.0/2:00:00".

Other formats with shortened time of day are also allowed like "M3.2.0/2" or even "M3.2.0" (midnight) are also allowed. Since the hour is local time, it can also be negative "M3.2.0/-1".

Constructor & Destructor Documentation

◆ LocalTimeChange()

LocalTimeChange::LocalTimeChange ( const char *  str)

Constructs a time change object with a string format (calls parse())

Parameters
strthe time change string to parse

The time change string is part of the POSIX timezone specification and looks something like "M3.2.0/2:00:00".

Member Function Documentation

◆ calculate()

time_t LocalTimeChange::calculate ( struct tm *  pTimeInfo,
LocalTimeHMS  tzAdjust 
) const

Calculate the time change in a given year.

On input, pTimeInfo must have a valid tm_year (121 = 2021) set.

On output, all struct tm values are set appropriately with UTC values of when the time change occurs.

◆ parse()

void LocalTimeChange::parse ( const char *  str)

Parses a time change string.

Parameters
strthe time change string to parse

The time change string is part of the POSIX timezone specification and looks something like "M3.2.0/2:00:00".

  • M3 indicates that DST starts on the 3rd month (March)
  • 2 is the week number (second week)
  • 0 is the day of week (0 = Sunday)
  • 2:00:00 at 2 AM local time, the transition occurs

Setting the week to 5 essentially means the last week of the month. If the month does not have a fifth week for that day of the week, then the fourth is used instead.


The documentation for this class was generated from the following files: