S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
p_time_c99.h
Go to the documentation of this file.
1/*
2 * Licensed to Systerel under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work
4 * for additional information regarding copyright ownership.
5 * Systerel licenses this file to you under the Apache
6 * License, Version 2.0 (the "License"); you may not use this
7 * file except in compliance with the License. You may obtain
8 * a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef PIKEOS_TIME_H
21#define PIKEOS_TIME_H
22
23#include <stdint.h>
24#include <stdio.h>
25
26struct tm
27{
28 int tm_sec;
29 int tm_min;
32 int tm_mon;
38 const char* __tm_zone;
39};
40
41/* Represent time in second */
42typedef int64_t time_t;
43
44/************************************************
45 * Public API *
46 *************************************************/
47
48size_t strftime(char* strBuffer, size_t maxSize, const char* format, const struct tm* pTime);
49
50/* MUSL implementation */
51
52time_t mktime(struct tm* tp);
53
54/* Timezone for the pikeos machine cannot be easily access, so we decide to not take in account Timezone.
55 * This mean that localtime_r and gmtime_r has the same behavior and will fill struct tm as if you were in UTC + 0.
56 * Impact in S2OPC code is minimal since absolute date time is only used to print logs. */
57struct tm* localtime_r(const time_t* restrict t, struct tm* restrict tm);
58struct tm* gmtime_r(const time_t* restrict t, struct tm* restrict tm);
59struct tm* gmtime(const time_t* restrict t);
60
61/************************************************
62 * Internal API *
63 *************************************************/
64
65int __month_to_secs(int, int);
66long long __year_to_secs(long long, int*);
67long long __tm_to_secs(const struct tm*);
68int __secs_to_tm(long long, struct tm*);
69void __secs_to_zone(long long, int, int*, long*, long*, const char**);
70
71#endif // PIKEOS_TIME_H
struct tm * gmtime(const time_t *restrict t)
void __secs_to_zone(long long, int, int *, long *, long *, const char **)
size_t strftime(char *strBuffer, size_t maxSize, const char *format, const struct tm *pTime)
int __secs_to_tm(long long, struct tm *)
int64_t time_t
Definition p_time_c99.h:42
time_t mktime(struct tm *tp)
int __month_to_secs(int, int)
struct tm * localtime_r(const time_t *restrict t, struct tm *restrict tm)
struct tm * gmtime_r(const time_t *restrict t, struct tm *restrict tm)
long long __tm_to_secs(const struct tm *)
long long __year_to_secs(long long, int *)
Definition p_time_c99.h:27
int tm_mon
Definition p_time_c99.h:32
int tm_year
Definition p_time_c99.h:33
int tm_hour
Definition p_time_c99.h:30
int tm_sec
Definition p_time_c99.h:28
int tm_isdst
Definition p_time_c99.h:36
int tm_yday
Definition p_time_c99.h:35
long __tm_gmtoff
Definition p_time_c99.h:37
int tm_mday
Definition p_time_c99.h:31
const char * __tm_zone
Definition p_time_c99.h:38
int tm_min
Definition p_time_c99.h:29
int tm_wday
Definition p_time_c99.h:34