sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
timezone.c
Go to the documentation of this file.
1
/*
2
# _____ ___ ____ ___ ____
3
# ____| | ____| | | |____|
4
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5
#-----------------------------------------------------------------------
6
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7
# Licenced under Academic Free License version 2.0
8
# Review ps2sdk README & LICENSE files for further details.
9
*/
10
15
16
#include <
time.h
>
17
#include <
stdio.h
>
18
#include <
stdlib.h
>
19
#include <
unistd.h
>
20
#include <fcntl.h>
21
#include <reent.h>
22
23
#include <
ps2sdkapi.h
>
24
#define OSD_CONFIG_NO_LIBCDVD
25
#include "
osd_config.h
"
26
27
void
_libcglue_timezone_update_impl()
28
{
29
/* Initialize timezone from PS2 OSD configuration */
30
int
tzOffset =
configGetTimezone
();
31
int
tzOffsetAbs = tzOffset < 0 ? -tzOffset : tzOffset;
32
int
hours = tzOffsetAbs / 60;
33
int
minutes = tzOffsetAbs - hours * 60;
34
int
daylight =
configIsDaylightSavingEnabled
();
35
static
char
tz[28];
36
#pragma GCC diagnostic push
37
#pragma GCC diagnostic ignored "-Wformat-overflow"
38
snprintf(tz,
sizeof
(tz),
"GMT%s%02i:%02i%s"
, tzOffset < 0 ?
"+"
:
"-"
, hours, minutes, daylight ?
"DST"
:
""
);
39
#pragma GCC diagnostic pop
40
setenv(
"TZ"
, tz, 1);
41
}
42
43
// Defined in newlib: newlib/libc/time/tzset_r.c
44
void
__attribute((weak)) _tzset_unlocked_r(
struct
_reent *reent_ptr);
45
__attribute__
((weak))
46
void
_libcglue_timezone_update()
47
{
48
// cppcheck-suppress knownConditionTrueFalse
49
if
(&_tzset_unlocked_r)
50
{
51
_libcglue_timezone_update_impl();
52
}
53
}
54
55
void
ps2sdk_setTimezone(
int
timezone) {
56
configSetTimezone
(timezone);
57
_libcglue_timezone_update();
58
}
59
60
void
ps2sdk_setDaylightSaving(
int
daylightSaving) {
61
configSetDaylightSavingEnabled
(daylightSaving);
62
_libcglue_timezone_update();
63
}
osd_config.h
configSetTimezone
void configSetTimezone(int offset)
Definition
osd_config.c:348
configGetTimezone
int configGetTimezone(void)
Definition
osd_config.c:314
configSetDaylightSavingEnabled
void configSetDaylightSavingEnabled(int enabled)
Definition
osd_config.c:423
configIsDaylightSavingEnabled
int configIsDaylightSavingEnabled(void)
Definition
osd_config.c:407
ps2sdkapi.h
stdio.h
stdlib.h
__attribute__
Definition
gif_registers.h:40
time.h
unistd.h
core
libcglue
src
timezone.c
Generated by
1.18.0