Filter results by

Older Versions

Older API versions are available as a download. To view, extract the file and open the index.html file in a web browser.

artik_time.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2017 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  */
18 
19 #ifndef __ARTIK_TIME_H__
20 #define __ARTIK_TIME_H__
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #include <stdint.h>
27 
28 #include "artik_error.h"
29 #include "artik_types.h"
30 
55 #define ARTIK_TIME_DFORMAT "%I:%M:%S-%w-%d/%m/%Y"
56 
63  typedef void *artik_alarm_handle;
64 
71  typedef struct {
75  unsigned int second;
79  unsigned int minute;
83  unsigned int hour;
87  unsigned int day;
91  unsigned int month;
95  unsigned int year;
99  unsigned int day_of_week;
103  unsigned int msecond;
104  } artik_time;
105 
112  typedef char artik_time_gmt;
113 
119  typedef unsigned int long artik_msecond;
120 
126  typedef enum {
127  ARTIK_TIME_UTC = 0,
128  ARTIK_TIME_GMT1,
129  ARTIK_TIME_GMT2,
130  ARTIK_TIME_GMT3,
131  ARTIK_TIME_GMT4,
132  ARTIK_TIME_GMT5,
133  ARTIK_TIME_GMT6,
134  ARTIK_TIME_GMT7,
135  ARTIK_TIME_GMT8,
136  ARTIK_TIME_GMT9,
137  ARTIK_TIME_GMT10,
138  ARTIK_TIME_GMT11,
139  ARTIK_TIME_GMT12
140  } artik_time_zone;
141 
147  typedef void(*alarm_callback)(void *user_data);
148 
156  typedef struct {
166  artik_error(*set_time) (artik_time date, artik_time_zone gmt);
176  artik_error(*get_time) (artik_time_zone gmt, artik_time * date);
192  artik_error(*get_time_str) (char *date_str, int size,
193  char *const format, artik_time_zone gmt);
200  artik_msecond(*get_tick) (void);
217  artik_error(*create_alarm_second) (artik_time_zone gmt,
218  artik_msecond value,
219  artik_alarm_handle * handle,
220  alarm_callback func,
221  void *user_data);
236  artik_error(*create_alarm_date) (artik_time_zone gmt,
237  artik_time value,
238  artik_alarm_handle * handle,
239  alarm_callback func,
240  void *user_data);
250  artik_error(*delete_alarm) (artik_alarm_handle handle);
261  artik_error(*get_delay_alarm) (artik_alarm_handle handle,
262  artik_msecond * msecond);
270  artik_error(*sync_ntp) (const char *hostname);
282  int (*compare_dates)(const artik_time *date1, const artik_time *date2);
292  artik_error(*convert_timestamp_to_time) (const int64_t
293  timestamp,
294  artik_time *date);
305  artik_error(*convert_time_to_timestamp) (const artik_time *date,
306  int64_t *timestamp);
307 
308 
309 
311 
312  extern artik_time_module time_module;
313 
314 #ifdef __cplusplus
315 }
316 #endif
317 #endif /* __ARTIK_TIME_H__ */
unsigned int day_of_week
Day of the week starting from Sunday (0-6)
Definition: artik_time.h:99
unsigned int month
Month starting from January (1-12)
Definition: artik_time.h:91
unsigned int minute
Minutes elapsed in the current hour (0-59)
Definition: artik_time.h:79
void(* alarm_callback)(void *user_data)
This callback function gets triggered after timeout.
Definition: artik_time.h:147
unsigned int day
Day of the month (1-31)
Definition: artik_time.h:87
Time module operations.
Definition: artik_time.h:156
unsigned int msecond
Milliseconds elapsed in the current second.
Definition: artik_time.h:103
Custom types.
char artik_time_gmt
Time gmt type.
Definition: artik_time.h:112
unsigned int long artik_msecond
Time millisecond type.
Definition: artik_time.h:119
artik_time_zone
Time zone type.
Definition: artik_time.h:126
int artik_error
Error type.
Definition: artik_error.h:35
unsigned int hour
Hours starting from midnight (0-23)
Definition: artik_time.h:83
Time storage type.
Definition: artik_time.h:71
unsigned int year
Year.
Definition: artik_time.h:95
unsigned int second
Seconds elapsed in the current minute (0-59)
Definition: artik_time.h:75
void * artik_alarm_handle
Alarm handle type.
Definition: artik_time.h:63
Error codes.
Last updated on: