Mstdlib-1.24.0
m_mtzfile.h
1/* The MIT License (MIT)
2 *
3 * Copyright (c) 2015 Monetra Technologies, LLC.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23
24#ifndef __M_MTZFILE_H__
25#define __M_MTZFILE_H__
26
27/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
28
29#include <mstdlib/base/m_defs.h>
30#include <mstdlib/base/m_types.h>
31#include <mstdlib/base/m_time.h>
32
33/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
34
35__BEGIN_DECLS
36
37/*! \addtogroup m_mtzfile Mstdlib TZ File
38 * \ingroup m_formats
39 *
40 * The Mstdlib TZ format is a simple way to describe timezone information. It is intended
41 * for use on systems that do not provide timezone information. Such as embedded systems.
42 * A time.zone file is provided in the formats/time directory in the source package
43 * which provides timezone descriptions for US, Canada, and Mexico.
44 *
45 * The format is an ini file which can be parsed with \link m_ini \endlink. However, functions
46 * are provided here which will parse and load the format into a M_time_tzs_t object.
47 *
48 * Format description:
49 *
50 * Section define zones. Aliases are alternate names that identify the zone.
51 * The section must have an offset and abbreviation. The offset is assumed negative unless
52 * the value start explicitly with '+'. DST offsets and abbreviations are used when a DST
53 * rule is in effect. A DST rule is a Posix DST rule with the first part replaced with a year
54 * (the year the rule applies) followed by a ';'. For DST rules only the M day format is supported.
55 *
56 * Example:
57 *
58 * \code{.ini}
59 * [EST5]
60 * offset=5
61 * abbr=EST
62 *
63 * [EST5EDT]
64 * alias=America/New_York
65 * alias=America/Detroit
66 * alias=America/Indiana/Indianapolis
67 * offset=5
68 * offset_dst=4
69 * abbr=EST
70 * abbr_dst=EDT
71 * dst=2007;M3.2.0/02:00:00,M11.1.0/02:00:00
72 * dst=1987;M4.1.0/02:00:00,M10.-1.0/02:00:00
73 * \endcode
74 *
75 * @{
76 */
77
78
79/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
80
81/*! Add Mstdlib TZ from a file.
82 *
83 *
84 * \param[in,out] tzs The tz db.
85 * \param[in] path The file and path to load.
86 * \param[out] err_line The line number if failure is due to ini parse failure.
87 * \param[out] err_sect The section that failed to parse if a parse failure not due to an ini parse failure.
88 * \param[out] err_data The data that caused the failure.
89 *
90 * \return Success on success. Otherwise error condition.
91 */
92M_API M_time_result_t M_mtzfile_tzs_add_file(M_time_tzs_t *tzs, const char *path, size_t *err_line, char **err_sect, char **err_data);
93
94
95/*! Add Mstdlib TZ from a string.
96 *
97 * \param[in,out] tzs The tz db.
98 * \param[in] data The data to load.
99 * \param[out] err_line The line number if failure is due to ini parse failure.
100 * \param[out] err_sect The section that failed to parse if a parse failure not due to an ini parse failure.
101 * \param[out] err_data The data that caused the failure.
102 *
103 * \return Success on success. Otherwise error condition.
104 *
105 * \see M_mtzfile_tzs_add_file for details of the format.
106 */
107M_API M_time_result_t M_mtzfile_tzs_add_str(M_time_tzs_t *tzs, const char *data, size_t *err_line, char **err_sect, char **err_data);
108
109/*! @} */
110
111__END_DECLS
112
113#endif /* __M_TZFILE_H__ */
M_time_result_t M_mtzfile_tzs_add_file(M_time_tzs_t *tzs, const char *path, size_t *err_line, char **err_sect, char **err_data)
M_time_result_t M_mtzfile_tzs_add_str(M_time_tzs_t *tzs, const char *data, size_t *err_line, char **err_sect, char **err_data)
struct M_time_tzs M_time_tzs_t
Definition: m_time.h:200
M_time_result_t
Definition: m_time.h:244