ESP DateTime  0.2.0
Date Time Functions and Classes for ESP8266 and ESP32
DateTimeParts Struct Reference

DateTime Parts struct, similar to struct tm in <time.h>, containing a calendar date and time broken down into its components, but more readable, include some useful getter methods. More...

#include <DateTime.h>

Public Member Functions

time_t getTime () const
 Get internal timestamp, in seconds. More...
 
int getTimeZone () const
 Get internal timezone offset. More...
 
int getYear () const
 Get the year (format: 19xx, 20xx) More...
 
int getMonth () const
 Get months since January (0-11) More...
 
int getYearDay () const
 Get days since January 1 (0-365) More...
 
int getMonthDay () const
 Get day of the month (1-31) More...
 
int getWeekDay () const
 Get days since Sunday (0-6) More...
 
int getHours () const
 Get hours since midnight (0-23) More...
 
int getMinutes () const
 Get minutes after the hour (0-59) More...
 
int getSeconds () const
 Get seconds after the minute (0-60) More...
 
String format (const char *fmt) const
 Foramt current time to string representation. More...
 
String toString () const
 Get string representation of current time. More...
 

Static Public Member Functions

static DateTimeParts from (const time_t timeSecs, const int timeZone=0)
 factory method for constructing DateTimeParts from timestamp and timezone. More...
 
static DateTimeParts from (DateTimeClass *dateTime)
 factory method for constructing DateTimeParts from DateTimeClass object. More...
 

Public Attributes

const time_t _ts
 
const int _tz
 
const struct tm * _tm
 

Detailed Description

DateTime Parts struct, similar to struct tm in <time.h>, containing a calendar date and time broken down into its components, but more readable, include some useful getter methods.

Member Function Documentation

◆ format()

String DateTimeParts::format ( const char *  fmt) const

Foramt current time to string representation.

Parameters
fmtformat string for strftime
Returns
String string representation of current time

◆ from() [1/2]

DateTimeParts DateTimeParts::from ( const time_t  timeSecs,
const int  timeZone = 0 
)
static

factory method for constructing DateTimeParts from timestamp and timezone.

Parameters
timeSecstimestamp in seconds since 1970
timeZonetimezone offset (-11,+13)
Returns
DateTimeParts DateTimeParts object

◆ from() [2/2]

DateTimeParts DateTimeParts::from ( DateTimeClass dateTime)
static

factory method for constructing DateTimeParts from DateTimeClass object.

Parameters
dateTimeDateTimeClass object
Returns
DateTimeParts DateTimeParts object

◆ getHours()

int DateTimeParts::getHours ( ) const
inline

Get hours since midnight (0-23)

Returns
int hours

◆ getMinutes()

int DateTimeParts::getMinutes ( ) const
inline

Get minutes after the hour (0-59)

Returns
int minutes

◆ getMonth()

int DateTimeParts::getMonth ( ) const
inline

Get months since January (0-11)

Returns
int month value

◆ getMonthDay()

int DateTimeParts::getMonthDay ( ) const
inline

Get day of the month (1-31)

Returns
int month day

◆ getSeconds()

int DateTimeParts::getSeconds ( ) const
inline

Get seconds after the minute (0-60)

Returns
int seconds

◆ getTime()

time_t DateTimeParts::getTime ( ) const
inline

Get internal timestamp, in seconds.

Returns
time_t timestamp, in seconds

◆ getTimeZone()

int DateTimeParts::getTimeZone ( ) const
inline

Get internal timezone offset.

Returns
int timezone offset

◆ getWeekDay()

int DateTimeParts::getWeekDay ( ) const
inline

Get days since Sunday (0-6)

Returns
int day of week

◆ getYear()

int DateTimeParts::getYear ( ) const
inline

Get the year (format: 19xx, 20xx)

Returns
int year value

◆ getYearDay()

int DateTimeParts::getYearDay ( ) const
inline

Get days since January 1 (0-365)

Returns
int day of year

◆ toString()

String DateTimeParts::toString ( ) const

Get string representation of current time.

Returns
String string representation of current time

Member Data Documentation

◆ _tm

const struct tm* DateTimeParts::_tm

struct tm variable, internal

◆ _ts

const time_t DateTimeParts::_ts

timestamp variable, internal

◆ _tz

const int DateTimeParts::_tz

timezone variable, internal


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