51e0c8e29a1f04741892c08091523654b0c5d4ec
[citadel.git] / citadel / server / default_timezone.c
1 //
2 // Copyright (c) 1987-2024 by the citadel.org team
3 //
4 // This program is open source software.  Use, duplication, or disclosure
5 // are subject to the terms of the GNU General Public License, version 3.
6
7 #include "sysdep.h"
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include <sys/types.h>
11 #include <limits.h>
12 #include <stdio.h>
13 #include <string.h>
14 #include <strings.h>
15 #include <syslog.h>
16 #include <libical/ical.h>
17 #include <libcitadel.h>
18 #include "citadel_defs.h"
19 #include "server.h"
20 #include "citserver.h"
21 #include "sysdep_decls.h"
22 #include "support.h"
23 #include "config.h"
24 #include "default_timezone.h"
25 #include "ctdl_module.h"
26
27
28 // Figure out which time zone needs to be used for timestamps that are
29 // not UTC and do not have a time zone specified.
30 icaltimezone *get_default_icaltimezone(void) {
31
32         icaltimezone *zone = NULL;
33         char *default_zone_name = CtdlGetConfigStr("c_default_cal_zone");
34
35         if (!zone) {
36                 zone = icaltimezone_get_builtin_timezone(default_zone_name);
37         }
38         if (!zone) {
39                 syslog(LOG_ERR, "ical: Unable to load '%s' time zone.  Defaulting to UTC.", default_zone_name);
40                 zone = icaltimezone_get_utc_timezone();
41         }
42         if (!zone) {
43                 syslog(LOG_ERR, "ical: unable to load UTC time zone!");
44         }
45
46         return zone;
47 }