StuBS
DateTime Struct Reference

Date and Time. More...

#include <object/time.h>

Public Member Functions

 DateTime ()
 Default constructor.
 
 DateTime (uint32_t epoch)
 Construct from a timestamp (Unix epoch time)
 
uint32_t toTimestamp () const
 Convert to Unix epoch time.
 

Public Attributes

uint8_t second
 Second (0 - 59)
 
uint8_t minute
 Minute (0 - 59)
 
uint8_t hour
 Hour (0 - 23)
 
uint8_t weekday
 Weekday (1 (Sun) - 7 (Sat))
 
uint8_t day
 Day of Month (1 - 31)
 
uint8_t month
 Month (1 - 12)
 
uint16_t year
 Year (0 (2000) - 99 (2099))
 

Static Public Attributes

static const char *const weekdays [8]
 Name of weekdays.
 
static const char *const months [13]
 Name of months.
 

Detailed Description

Date and Time.

Note
only Dates between 1 January 2000 and 31 December 2099 are supported

Constructor & Destructor Documentation

◆ DateTime() [1/2]

DateTime::DateTime ( )
inline

Default constructor.

◆ DateTime() [2/2]

DateTime::DateTime ( uint32_t  epoch)
explicit

Construct from a timestamp (Unix epoch time)

Member Function Documentation

◆ toTimestamp()

uint32_t DateTime::toTimestamp ( ) const

Convert to Unix epoch time.

Returns
Seconds since 1 January 1970

Member Data Documentation

◆ second

uint8_t DateTime::second

Second (0 - 59)

◆ minute

uint8_t DateTime::minute

Minute (0 - 59)

◆ hour

uint8_t DateTime::hour

Hour (0 - 23)

◆ weekday

uint8_t DateTime::weekday

Weekday (1 (Sun) - 7 (Sat))

◆ day

uint8_t DateTime::day

Day of Month (1 - 31)

◆ month

uint8_t DateTime::month

Month (1 - 12)

◆ year

uint16_t DateTime::year

Year (0 (2000) - 99 (2099))

◆ weekdays

const char *const DateTime::weekdays
static
Initial value:
=
{ nullptr, "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }

Name of weekdays.

◆ months

const char *const DateTime::months
static
Initial value:
=
{ nullptr, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" }

Name of months.


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