$darkmode
Libical API Documentation 4.0 STABLE VERSION Visit the v3.0 documentation
vcardtime.h
Go to the documentation of this file.
1 /*======================================================================
2  FILE: vcardtime.h
3  CREATOR: Ken Murchison 24 Aug 2022
4 
5  SPDX-FileCopyrightText: 2022, Fastmail Pty. Ltd. (https://fastmail.com)
6  SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
7  ======================================================================*/
8 
14 #ifndef VCARDTIME_H
15 #define VCARDTIME_H
16 
17 #include "libical_vcard_export.h"
18 
19 #include <stdbool.h>
20 
21 typedef struct vcardtimetype {
22  int year; /* 0000-9999 */
23  int month; /* 01 (Jan) to 12 (Dec). */
24  int day; /* 01-28/29/30/31 depending on month and leap year */
25  int hour; /* 00-23 */
26  int minute; /* 00-59 */
27  int second; /* 00-58/59/60 depending on leap second */
28  /* vCard v3 allows fractional sec, but v4 does not. We parse and ignore */
29  int utcoffset; /* -720 to +840 minutes (-12:00 to +14:00) */
31 
32 #define vcardtime_null_date() vcardtime_null_datetime()
33 #define vcardtime_null_time() vcardtime_null_datetime()
34 #define vcardtime_null_timestamp() vcardtime_null_datetime()
35 
36 LIBICAL_VCARD_EXPORT vcardtimetype vcardtime_null_datetime(void);
37 LIBICAL_VCARD_EXPORT vcardtimetype vcardtime_current_utc_time(void);
38 
39 LIBICAL_VCARD_EXPORT bool vcardtime_is_null_datetime(const vcardtimetype t);
40 LIBICAL_VCARD_EXPORT bool vcardtime_is_time(const vcardtimetype t);
41 LIBICAL_VCARD_EXPORT bool vcardtime_is_date(const vcardtimetype t);
42 LIBICAL_VCARD_EXPORT bool vcardtime_is_datetime(const vcardtimetype t);
43 LIBICAL_VCARD_EXPORT bool vcardtime_is_timestamp(const vcardtimetype t);
44 LIBICAL_VCARD_EXPORT bool vcardtime_is_utc(const vcardtimetype t);
45 LIBICAL_VCARD_EXPORT bool vcardtime_is_leap_year(const int year);
46 LIBICAL_VCARD_EXPORT bool vcardtime_is_valid_time(const struct vcardtimetype t);
47 
48 #define VCARDTIME_BARE_TIME (0x1) /* 'T' not needed for TIME */
49 #define VCARDTIME_AS_V4 (0x2) /* allow partial date and/or time */
50 
51 LIBICAL_VCARD_EXPORT const char *vcardtime_as_vcard_string(const vcardtimetype t,
52  unsigned flags);
53 LIBICAL_VCARD_EXPORT char *vcardtime_as_vcard_string_r(const vcardtimetype t,
54  unsigned flags);
55 
56 LIBICAL_VCARD_EXPORT vcardtimetype vcardtime_from_string(const char *str,
57  int is_bare_time);
58 
59 #endif /* VCARDTIME_H */