libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_date_time.h File Reference

Go to the source code of this file.

Data Structures

struct  GblDateTimeClass
 
struct  GblDate
 
struct  GblTime
 
struct  GblDateTime
 

Macros

#define GBL_DATE_TIME_TYPE
 
#define GBL_DATE_TIME_CLASS(klass)
 
#define GBL_DATE_TIME_ISO8601_STRING_SIZE
 
Second Conversions

Defines for second conversion factors

#define GBL_TIME_MSECS_PER_SEC
 
#define GBL_TIME_USECS_PER_SEC
 
#define GBL_TIME_NSECS_PER_SEC
 
Start Dates

Initial dates of epochs

#define GBL_DATE_GREGORIAN_YEAR_FIRST
 
#define GBL_DATE_UNIX_EPOCH_YEAR
 
#define GBL_DATE_UNIX_EPOCH_MONTH
 
#define GBL_DATE_UNIX_EPOCH_DAY
 
Broken-down Time

Defines for working with broken-down time

#define GBL_DATE_TIME_BROKEN_DOWN_YEAR_FIRST
 
#define GBL_DATE_TIME_BROKEN_DOWN_YEAR_MIN
 
#define GBL_DATE_TIME_BROKEN_DOWN_MONTH_OFFSET
 
Formatting

Defines used when formatting and stringifying

#define GBL_DATE_TIME_FORMAT_BUFFER_SIZE_INCREMENT
 
#define GBL_DATE_TIME_FORMAT_BUFFER_SIZE_MULTIPLIER_MAX
 

Typedefs

typedef GblEnum GblMonth
 
typedef GblEnum GblWeekDay
 
typedef int32_t GblYear
 
typedef int32_t GblDay
 
typedef int32_t GblNanoSecond
 
typedef int64_t GblSecond
 
typedef int32_t GblMinute
 
typedef int32_t GblHour
 
typedef struct timespec GblTimeSpec
 

Enumerations

enum  GblMonth
 
enum  GblWeekDay
 

Functions

Type System

Type declarations for GblVariant time type

GblType GblDateTime_type (void)
 
Date Static Methods

Non-member functions for date management

GblBool GblDate_isLeapYear (GblYear year)
 
GblDay GblDate_monthDays (GblMonth month, GblYear year)
 
const char * GblDate_monthStr (GblMonth month)
 
const char * GblDate_monthStrShort (GblMonth month)
 
const char * GblDate_weekDayStr (GblWeekDay weekDay)
 
const char * GblDate_weekDayStrShort (GblWeekDay weekDay)
 

Detailed Description

Date and time conversions and utilities.

Todo:
  • GblDateTime_fromIso8601()
  • double GblDateTime_toJulian(): higher res, with seconds
  • toIso8601() string corrupting with msec resolution
  • GblDateTime_format() support ms, us, ns
  • GblDateTime_parse() support ms, us, ns
  • are we misnaming GMT as UTC anywhere?
  • GstDateTime maintains whether fields have been set or not...
Author
2023 Falco Girgis

Definition in file gimbal_date_time.h.

Macro Definition Documentation

◆ GBL_DATE_TIME_TYPE

#define GBL_DATE_TIME_TYPE

Definition at line 22 of file gimbal_date_time.h.

◆ GBL_DATE_TIME_CLASS

#define GBL_DATE_TIME_CLASS (   klass)

Definition at line 23 of file gimbal_date_time.h.

◆ GBL_TIME_MSECS_PER_SEC

#define GBL_TIME_MSECS_PER_SEC

Number of milliseconds per second.

Definition at line 29 of file gimbal_date_time.h.

◆ GBL_TIME_USECS_PER_SEC

#define GBL_TIME_USECS_PER_SEC

Number of microseconds per second.

Definition at line 30 of file gimbal_date_time.h.

◆ GBL_TIME_NSECS_PER_SEC

#define GBL_TIME_NSECS_PER_SEC

Number of nanoseconds per second.

Definition at line 31 of file gimbal_date_time.h.

◆ GBL_DATE_GREGORIAN_YEAR_FIRST

#define GBL_DATE_GREGORIAN_YEAR_FIRST

First year in Gregorian calendar.

Definition at line 38 of file gimbal_date_time.h.

◆ GBL_DATE_UNIX_EPOCH_YEAR

#define GBL_DATE_UNIX_EPOCH_YEAR

Year of the Unix epoch.

Definition at line 39 of file gimbal_date_time.h.

◆ GBL_DATE_UNIX_EPOCH_MONTH

#define GBL_DATE_UNIX_EPOCH_MONTH

Month of the Unix epoch.

Definition at line 40 of file gimbal_date_time.h.

◆ GBL_DATE_UNIX_EPOCH_DAY

#define GBL_DATE_UNIX_EPOCH_DAY

Day of the unix epoch.

Definition at line 41 of file gimbal_date_time.h.

◆ GBL_DATE_TIME_BROKEN_DOWN_YEAR_FIRST

#define GBL_DATE_TIME_BROKEN_DOWN_YEAR_FIRST

Year offset of a broken-down time's date.

Definition at line 48 of file gimbal_date_time.h.

◆ GBL_DATE_TIME_BROKEN_DOWN_YEAR_MIN

#define GBL_DATE_TIME_BROKEN_DOWN_YEAR_MIN

The oldest year a broken-down time can handle by spec.

Definition at line 49 of file gimbal_date_time.h.

◆ GBL_DATE_TIME_BROKEN_DOWN_MONTH_OFFSET

#define GBL_DATE_TIME_BROKEN_DOWN_MONTH_OFFSET

Month offset from GblMonth to a broken-down month.

Definition at line 50 of file gimbal_date_time.h.

◆ GBL_DATE_TIME_FORMAT_BUFFER_SIZE_INCREMENT

#define GBL_DATE_TIME_FORMAT_BUFFER_SIZE_INCREMENT

Size increment when resizing format buffers.

Definition at line 57 of file gimbal_date_time.h.

◆ GBL_DATE_TIME_FORMAT_BUFFER_SIZE_MULTIPLIER_MAX

#define GBL_DATE_TIME_FORMAT_BUFFER_SIZE_MULTIPLIER_MAX

Maximum number of size increments for format buffers.

Definition at line 58 of file gimbal_date_time.h.

◆ GBL_DATE_TIME_ISO8601_STRING_SIZE

#define GBL_DATE_TIME_ISO8601_STRING_SIZE

Required buffer size for going to an ISO8601-formatted string.

Definition at line 61 of file gimbal_date_time.h.

Typedef Documentation

◆ GblMonth

typedef GblEnum GblMonth

Represents a month of the 12-month year.

Definition at line 66 of file gimbal_date_time.h.

◆ GblWeekDay

Represents a day of the 7-day week.

Definition at line 83 of file gimbal_date_time.h.

◆ GblYear

typedef int32_t GblYear

Represents a calendar year.

Definition at line 94 of file gimbal_date_time.h.

◆ GblDay

typedef int32_t GblDay

Represents a 24-hour day within a month (0-31)

Definition at line 95 of file gimbal_date_time.h.

◆ GblNanoSecond

typedef int32_t GblNanoSecond

Represents a nanosecond within a second (0-1000000000.

Definition at line 96 of file gimbal_date_time.h.

◆ GblSecond

typedef int64_t GblSecond

Represents a second in a 60-second minute (0-59)

Definition at line 97 of file gimbal_date_time.h.

◆ GblMinute

typedef int32_t GblMinute

Represents a minute in a 60-minute hour (0-59)

Definition at line 98 of file gimbal_date_time.h.

◆ GblHour

typedef int32_t GblHour

Represents an hour within a 24-hour day (0-23)

Definition at line 99 of file gimbal_date_time.h.

◆ GblTimeSpec

typedef struct timespec GblTimeSpec

Represents the difference between two GblTime instances.

Definition at line 102 of file gimbal_date_time.h.

Enumeration Type Documentation

◆ GblMonth

enum GblMonth
Enumerator
GBL_MONTH_JANUARY 

January.

GBL_MONTH_FEBRUARY 

February.

GBL_MONTH_MARCH 

March.

GBL_MONTH_APRIL 

April.

GBL_MONTH_MAY 

May.

GBL_MONTH_JUNE 

June.

GBL_MONTH_JULY 

July.

GBL_MONTH_AUGUST 

August.

GBL_MONTH_SEPTEMBER 

September.

GBL_MONTH_OCTOBER 

October.

GBL_MONTH_NOVEMBER 

November.

GBL_MONTH_DECEMBER 

December.

GBL_MONTH_COUNT 

Months/Year.

Definition at line 66 of file gimbal_date_time.h.

66 {
67 GBL_MONTH_JANUARY = 1, //!< January
68 GBL_MONTH_FEBRUARY, //!< February
69 GBL_MONTH_MARCH, //!< March
70 GBL_MONTH_APRIL, //!< April
71 GBL_MONTH_MAY, //!< May
72 GBL_MONTH_JUNE, //!< June
73 GBL_MONTH_JULY, //!< July
74 GBL_MONTH_AUGUST, //!< August
75 GBL_MONTH_SEPTEMBER, //!< September
76 GBL_MONTH_OCTOBER, //!< October
77 GBL_MONTH_NOVEMBER, //!< November
78 GBL_MONTH_DECEMBER, //!< December
79 GBL_MONTH_COUNT = 12 //!< Months/Year
80};
@ GBL_MONTH_COUNT
Months/Year.
@ GBL_MONTH_OCTOBER
October.
@ GBL_MONTH_DECEMBER
December.
@ GBL_MONTH_FEBRUARY
February.
@ GBL_MONTH_NOVEMBER
November.
@ GBL_MONTH_MAY
May.
@ GBL_MONTH_JULY
July.
@ GBL_MONTH_MARCH
March.
@ GBL_MONTH_APRIL
April.
@ GBL_MONTH_JANUARY
January.
@ GBL_MONTH_SEPTEMBER
September.
@ GBL_MONTH_JUNE
June.
@ GBL_MONTH_AUGUST
August.

◆ GblWeekDay

enum GblWeekDay
Enumerator
GBL_WEEK_DAY_SUNDAY 

Sunday.

GBL_WEEK_DAY_MONDAY 

Monday.

GBL_WEEK_DAY_TUESDAY 

Tuesday.

GBL_WEEK_DAY_WEDNESDAY 

Wednesday.

GBL_WEEK_DAY_THURSDAY 

Thursday.

GBL_WEEK_DAY_FRIDAY 

Friday.

GBL_WEEK_DAY_SATURDAY 

Saturday.

GBL_WEEK_DAY_COUNT 

Days/Week.

Definition at line 83 of file gimbal_date_time.h.

83 {
84 GBL_WEEK_DAY_SUNDAY, //!< Sunday
85 GBL_WEEK_DAY_MONDAY, //!< Monday
86 GBL_WEEK_DAY_TUESDAY, //!< Tuesday
87 GBL_WEEK_DAY_WEDNESDAY, //!< Wednesday
88 GBL_WEEK_DAY_THURSDAY, //!< Thursday
89 GBL_WEEK_DAY_FRIDAY, //!< Friday
90 GBL_WEEK_DAY_SATURDAY, //!< Saturday
91 GBL_WEEK_DAY_COUNT //!< Days/Week
92};
@ GBL_WEEK_DAY_TUESDAY
Tuesday.
@ GBL_WEEK_DAY_MONDAY
Monday.
@ GBL_WEEK_DAY_SUNDAY
Sunday.
@ GBL_WEEK_DAY_THURSDAY
Thursday.
@ GBL_WEEK_DAY_SATURDAY
Saturday.
@ GBL_WEEK_DAY_FRIDAY
Friday.
@ GBL_WEEK_DAY_WEDNESDAY
Wednesday.
@ GBL_WEEK_DAY_COUNT
Days/Week.

Function Documentation

◆ GblDate_isLeapYear()

GblBool GblDate_isLeapYear ( GblYear  year)

Returns GBL_TRUE if the given year was a leap year, otherwise returns GBL_FALSE.

◆ GblDate_monthDays()

GblDay GblDate_monthDays ( GblMonth  month,
GblYear  year 
)

Returns the number of days in the given month of the given year.

◆ GblDate_monthStr()

const char * GblDate_monthStr ( GblMonth  month)

Returns the string name of the given month.

◆ GblDate_monthStrShort()

const char * GblDate_monthStrShort ( GblMonth  month)

Returns the short-handed string name of the given month.

◆ GblDate_weekDayStr()

const char * GblDate_weekDayStr ( GblWeekDay  weekDay)

Returns the string name of the given weekday.

◆ GblDate_weekDayStrShort()

const char * GblDate_weekDayStrShort ( GblWeekDay  weekDay)

Returns the short-handed string name of the given weekday.