Dates
This page has been automatically translated using the Google Translate API services. We are working on improving texts. Thank you for your understanding and patience.
Date manipulation functions.
Header
#include <core/date.h>
Functions
| Date | date_system (void) |
| Date | date_pack (...) |
| Date | date_add_seconds (...) |
| Date | date_add_minutes (...) |
| Date | date_add_hours (...) |
| Date | date_add_days (...) |
| int16_t | date_year (void) |
| int | date_cmp (...) |
| int64_t | date_ellapsed_seconds (...) |
| bool_t | date_between (...) |
| bool_t | date_is_null (...) |
| bool_t | date_is_valid (...) |
| week_day_t | date_weekday (...) |
| const String* | date_format (...) |
Types and Constants
| Date | kDATE_NULL |
A series of functions are included within core to work with dates.
- Use date_system to get the system date.
- Use date_add_seconds to increment a given date.
- Use date_cmp to compare two dates.
kDATE_NULL
Date kDATE_NULL;
Represents an invalid date.
date_system ()
Get the system date.
Date date_system(void);
Return
The current date.
date_pack ()
Pack a date.
Date date_pack(const int16_t year, const uint8_t month, const uint8_t mday, const uint8_t hour, const uint8_t minute, const uint8_t second);
| year | Year. |
| month | Month number (1,12). |
| mday | Day of the month (1,31). |
| hour | Hour (0,23). |
| minute | Minute (0,59). |
| second | Second (0,59). |
Return
The packaged date.
date_add_seconds ()
Calculate the date resulting from adding an amount of seconds to another date.
Date date_add_seconds(const Date *date, int32_t seconds);
| date | The base date. |
| seconds | The number of seconds. If it is positive we will obtain a future date. If negative, a past date. |
Return
The result date.
date_add_minutes ()
Calculate the date resulting from adding an amount of minutes to another date.
Date date_add_minutes(const Date *date, int32_t minutes);
| date | The base date. |
| minutes | The number of minutes. If it is positive we will obtain a future date. If negative, a past date. |
Return
The result date.
date_add_hours ()
Calculate the date resulting from adding an amount of hours to another date.
Date date_add_hours(const Date *date, int32_t hours);
| date | The base date. |
| hours | The number of hours. If it is positive we will obtain a future date. If negative, a past date. |
Return
The result date.
date_add_days ()
Calculate the date resulting from adding an amount of days to another date.
Date date_add_days(const Date *date, int32_t days);
| date | The base date. |
| days | The number of days. If it is positive we will obtain a future date. If negative, a past date. |
Return
The result date.
date_year ()
Obtiene el año actual.
int16_t date_year(void);
Return
El año actual.
date_cmp ()
Compare two dates. The most recent date is considered greater.
int date_cmp(const Date *date1, const Date *date2);
| date1 | First date to compare. |
| date2 | Second date to compare. |
Return
Comparison result.
date_ellapsed_seconds ()
Calculates the number of seconds elapsed between two dates.
int64_t date_ellapsed_seconds(const Date *from, const Date *to);
| from | Start date. |
| to | Final date. |
Return
Number of seconds. It can be negative, if from is after to.
date_between ()
Check if a date is within a range.
bool_t date_between(const Date *date, const Date *from, const Date *to);
| date | Date to check. |
| from | Start date. |
| to | Final date. |
Return
TRUE if date is between from and to.
date_is_null ()
Checks if a date is null.
bool_t date_is_null(const Date *date);
| date | Date to check. |
Return
TRUE if date is null.
date_is_valid ()
Checks if a date is valid.
bool_t date_is_valid(const Date *date);
| date | Date to check. |
Return
TRUE if date is valid.
date_weekday ()
Calculates the day of the week of a date.
week_day_t date_weekday(const Date *date);
| date | Date. |
Return
Weekday.
date_format ()
Returns a string with a formatted date.
const String* date_format(const Date *date, const char_t *format);
| date | Date. |
| format | The specified format, based on |
Return
String with date.
Remarks
See Date conversion.


