date_time.c File Reference

Date and time management. More...

#include <stdio.h>
#include <string.h>
#include "date_time.h"

Go to the source code of this file.

Functions

const char_tformatSystemTime (systime_t time, char_t *str)
 Format system time. More...
 
const char_tformatDate (const DateTime *date, char_t *str)
 Format date. More...
 
void getCurrentDate (DateTime *date)
 Get current date and time. More...
 
__weak_func time_t getCurrentUnixTime (void)
 Get current time. More...
 
void convertUnixTimeToDate (time_t t, DateTime *date)
 Convert Unix timestamp to date. More...
 
time_t convertDateToUnixTime (const DateTime *date)
 Convert date to Unix timestamp. More...
 
int_t compareDateTime (const DateTime *date1, const DateTime *date2)
 Compare dates. More...
 
uint8_t computeDayOfWeek (uint16_t y, uint8_t m, uint8_t d)
 Calculate day of week. More...
 

Detailed Description

Date and time management.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file date_time.c.

Function Documentation

◆ compareDateTime()

int_t compareDateTime ( const DateTime date1,
const DateTime date2 
)

Compare dates.

Parameters
[in]date1Pointer to the first date
[in]date2Pointer to the second date
Returns
Comparison result

Definition at line 304 of file date_time.c.

◆ computeDayOfWeek()

uint8_t computeDayOfWeek ( uint16_t  y,
uint8_t  m,
uint8_t  d 
)

Calculate day of week.

Parameters
[in]yYear
[in]mMonth of year (in range 1 to 12)
[in]dDay of month (in range 1 to 31)
Returns
Day of week (in range 1 to 7)

Definition at line 353 of file date_time.c.

◆ convertDateToUnixTime()

time_t convertDateToUnixTime ( const DateTime date)

Convert date to Unix timestamp.

Parameters
[in]datePointer to a structure representing the date and time
Returns
Unix timestamp

Definition at line 260 of file date_time.c.

◆ convertUnixTimeToDate()

void convertUnixTimeToDate ( time_t  t,
DateTime date 
)

Convert Unix timestamp to date.

Parameters
[in]tUnix timestamp
[out]datePointer to a structure representing the date and time

Definition at line 198 of file date_time.c.

◆ formatDate()

const char_t* formatDate ( const DateTime date,
char_t str 
)

Format date.

Parameters
[in]datePointer to a structure representing the date
[out]strNULL-terminated string representing the specified date
Returns
Pointer to the formatted string

Definition at line 133 of file date_time.c.

◆ formatSystemTime()

const char_t* formatSystemTime ( systime_t  time,
char_t str 
)

Format system time.

Parameters
[in]timeSystem time
[out]strNULL-terminated string representing the specified time
Returns
Pointer to the formatted string

Definition at line 77 of file date_time.c.

◆ getCurrentDate()

void getCurrentDate ( DateTime date)

Get current date and time.

Parameters
[out]datePointer to a structure representing the date and time

Definition at line 165 of file date_time.c.

◆ getCurrentUnixTime()

__weak_func time_t getCurrentUnixTime ( void  )

Get current time.

Returns
Unix timestamp

Definition at line 180 of file date_time.c.