Libical API Documentation 4.0 UNRELEASED Go to the stable 3.0 documentation
Loading...
Searching...
No Matches
vcardtime.h
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
9#ifndef VCARDTIME_H
10#define VCARDTIME_H
11
12#include "libical_vcard_export.h"
13
14#include <stdbool.h>
15
16typedef struct vcardtimetype {
17 int year; /* 0000-9999 */
18 int month; /* 01 (Jan) to 12 (Dec). */
19 int day; /* 01-28/29/30/31 depending on month and leap year */
20 int hour; /* 00-23 */
21 int minute; /* 00-59 */
22 int second; /* 00-58/59/60 depending on leap second */
23 /* vCard v3 allows fractional sec, but v4 does not. We parse and ignore */
24 int utcoffset; /* -720 to +840 minutes (-12:00 to +14:00) */
26
27#define vcardtime_null_date() vcardtime_null_datetime()
28#define vcardtime_null_time() vcardtime_null_datetime()
29#define vcardtime_null_timestamp() vcardtime_null_datetime()
30
31LIBICAL_VCARD_EXPORT vcardtimetype vcardtime_null_datetime(void);
32LIBICAL_VCARD_EXPORT vcardtimetype vcardtime_current_utc_time(void);
33
34LIBICAL_VCARD_EXPORT bool vcardtime_is_null_datetime(const vcardtimetype t);
35LIBICAL_VCARD_EXPORT bool vcardtime_is_time(const vcardtimetype t);
36LIBICAL_VCARD_EXPORT bool vcardtime_is_date(const vcardtimetype t);
37LIBICAL_VCARD_EXPORT bool vcardtime_is_datetime(const vcardtimetype t);
38LIBICAL_VCARD_EXPORT bool vcardtime_is_timestamp(const vcardtimetype t);
39LIBICAL_VCARD_EXPORT bool vcardtime_is_utc(const vcardtimetype t);
40LIBICAL_VCARD_EXPORT bool vcardtime_is_leap_year(const int year);
41LIBICAL_VCARD_EXPORT bool vcardtime_is_valid_time(const struct vcardtimetype t);
42
43#define VCARDTIME_BARE_TIME (0x1) /* 'T' not needed for TIME */
44#define VCARDTIME_AS_V4 (0x2) /* allow partial date and/or time */
45
46LIBICAL_VCARD_EXPORT const char *vcardtime_as_vcard_string(const vcardtimetype t,
47 unsigned flags);
48LIBICAL_VCARD_EXPORT char *vcardtime_as_vcard_string_r(const vcardtimetype t,
49 unsigned flags);
50
51LIBICAL_VCARD_EXPORT vcardtimetype vcardtime_from_string(const char *str,
52 int is_bare_time);
53
54#endif /* VCARDTIME_H */
Definition vcardtime.h:16