A timestamp representing a UTC 'point in time' associated with a specific timezone. More...

#include <ZonedTime.h>

Public Member Functions

 ZonedTime (time_t utc, const DateTime::ZoneInfo &zoneInfo)
 Construct a zoned time. More...
 
 ZonedTime (time_t utc=0)
 Construct a time in the UTC zone. More...
 
 ZonedTime (const ZonedTime &other)=default
 
 operator time_t () const
 
ZonedTime toUtc () const
 Get a ZonedTime instance translated into the UTC zone This does nothing more than replace the contained zone information with UTC, which has tag "UTC", no offset and no daylight savings. More...
 
time_t local () const
 Obtain the time_t value adjusted for local time. More...
 
const DateTime::ZoneInfogetZoneInfo () const
 Get instance zone information. More...
 
const DateTime::ZoneInfo::Tagtag () const
 
int16_t offsetMins () const
 
int offsetSecs () const
 
bool isDst () const
 
String toString () const
 Obtain default formatted string. More...
 
Format time using <tt>DateTime</tt>
See also
See DateTime::format() for details
String format (const char *formatString) const
 
String format (const String &formatString) const
 
String toISO8601 () const
 

Static Public Member Functions

static void setDefaultFormat (const String &format)
 Set the default format for displaying zoned times. More...
 

Detailed Description

A timestamp representing a UTC 'point in time' associated with a specific timezone.

Derivation of the correct DateTime::ZoneInfo value is complex and typically managed by an external library, such as :library:Timezone.

The implicit time_t value for a ZonedTime is the corresponding UTC time. All comparisons or arithmetic operations will therefore operate using this value. This means two ZonedTime objects will be considered equal if their corresponding UTC timestamps match, even if they derive from different timezones.

To obtain the time_t value with local offset applied, use local():

    DateTime dtLocal(zonedTime.local());

There is no support in this class for manipulating time or zone information directly. This should be done using the raw time_t value and a new ZonedTime object constructed.

Constructor & Destructor Documentation

◆ ZonedTime() [1/3]

ZonedTime::ZonedTime ( time_t  utc,
const DateTime::ZoneInfo zoneInfo 
)
inline

Construct a zoned time.

Parameters
utc
zoneInfo

◆ ZonedTime() [2/3]

ZonedTime::ZonedTime ( time_t  utc = 0)
inlineexplicit

Construct a time in the UTC zone.

◆ ZonedTime() [3/3]

ZonedTime::ZonedTime ( const ZonedTime other)
default

Member Function Documentation

◆ format() [1/2]

String ZonedTime::format ( const char *  formatString) const
inline

◆ format() [2/2]

String ZonedTime::format ( const String formatString) const
inline

◆ getZoneInfo()

const DateTime::ZoneInfo& ZonedTime::getZoneInfo ( ) const
inline

Get instance zone information.

◆ isDst()

bool ZonedTime::isDst ( ) const
inline

◆ local()

time_t ZonedTime::local ( ) const
inline

Obtain the time_t value adjusted for local time.

◆ offsetMins()

int16_t ZonedTime::offsetMins ( ) const
inline

◆ offsetSecs()

int ZonedTime::offsetSecs ( ) const
inline

◆ operator time_t()

ZonedTime::operator time_t ( ) const
inline

◆ setDefaultFormat()

static void ZonedTime::setDefaultFormat ( const String format)
inlinestatic

Set the default format for displaying zoned times.

◆ tag()

const DateTime::ZoneInfo::Tag& ZonedTime::tag ( ) const
inline

◆ toISO8601()

String ZonedTime::toISO8601 ( ) const
inline

◆ toString()

String ZonedTime::toString ( ) const
inline

Obtain default formatted string.

◆ toUtc()

ZonedTime ZonedTime::toUtc ( ) const
inline

Get a ZonedTime instance translated into the UTC zone This does nothing more than replace the contained zone information with UTC, which has tag "UTC", no offset and no daylight savings.


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