iLLD_TC27xC  1.0
Ifx_DateTime.c
Go to the documentation of this file.
1 /**
2  * \file Ifx_DateTime.c
3  * \brief Date and time functions.
4  *
5  * \version iLLD_0_1_0_10
6  * \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
7  *
8  *
9  * IMPORTANT NOTICE
10  *
11  *
12  * Infineon Technologies AG (Infineon) is supplying this file for use
13  * exclusively with Infineon's microcontroller products. This file can be freely
14  * distributed within development tools that are supporting such microcontroller
15  * products.
16  *
17  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
18  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
20  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
21  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
22  *
23  */
24 
25 #include "Ifx_DateTime.h"
26 #include "SysSe/Bsp/Bsp.h"
27 
28 /* FIXME make compatible to unix time */
30 
31 /** \brief Get the real time
32  * Note that this function is valid only if DateTime_set() has been called */
34 {
35  sint32 seconds = (sint32)(now() / TimeConst_1s);
36 
37  seconds = seconds + g_DateTimeOffset;
38  dt->hours = seconds / 3600;
39  dt->minutes = seconds / 60;
40  dt->minutes = dt->minutes % 60;
41  dt->seconds = seconds % 60;
42 }
43 
44 
45 /** \brief Set the real time */
47 {
48  sint32 seconds = dt->seconds - ((sint32)(now() / TimeConst_1s));
49 
50  seconds = seconds + (3600 * dt->hours);
51  seconds = seconds + (60 * dt->minutes);
52  g_DateTimeOffset = seconds;
53 }