Retro Rocket Kernel
BASIC-Powered Operating System
clock.h File Reference
#include <kernel.h>
#include <stdint.h>

Data Structures

struct  datetime_t
 A representation of date and time. More...
 

Typedefs

typedef uint64_t time_t
 

Enumerations

enum  cmos_port_t { CMOS_ADDR = 0x70 , CMOS_DATA = 0x71 }
 CMOS IO port addresses. More...
 

Functions

const char * get_datetime_str ()
 Get the current date and time as a string. More...
 
void get_datetime (datetime_t *dt)
 Get the current date and time as a datetime_t. More...
 
void init_realtime_clock ()
 Initialise the realtime clock. More...
 
time_t time (time_t *t)
 POSIX time function returning time_t. More...
 
uint64_t day_of_year (uint64_t year, uint8_t month, uint8_t day)
 Calculate the day of year given any particular year, month an day Ported from js: https://stackoverflow.com/a/75032366/3022125. More...
 
int get_weekday_from_date (datetime_t *dt)
 

Detailed Description

Author
Craig Edwards (craig.nosp@m.edwa.nosp@m.rds@b.nosp@m.rain.nosp@m.box.c.nosp@m.c)

Typedef Documentation

◆ time_t

typedef uint64_t time_t

Enumeration Type Documentation

◆ cmos_port_t

CMOS IO port addresses.

Enumerator
CMOS_ADDR 
CMOS_DATA 

Function Documentation

◆ day_of_year()

uint64_t day_of_year ( uint64_t  year,
uint8_t  month,
uint8_t  day 
)

Calculate the day of year given any particular year, month an day Ported from js: https://stackoverflow.com/a/75032366/3022125.

Parameters
yearyear number
monthmonth number, 1-12
dayday number, 1-31
Returns
uint64_t days

◆ get_datetime()

void get_datetime ( datetime_t dt)

Get the current date and time as a datetime_t.

Parameters
dtdate and time to fill

◆ get_datetime_str()

const char* get_datetime_str ( )

Get the current date and time as a string.

Returns
const char* date and time

◆ get_weekday_from_date()

int get_weekday_from_date ( datetime_t dt)

◆ init_realtime_clock()

void init_realtime_clock ( )

Initialise the realtime clock.

◆ time()

time_t time ( time_t t)

POSIX time function returning time_t.

Parameters
tPointer to copy time value into if non-null
Returns
time_t Current time