mirror of
https://github.com/joel16/VitaShell.git
synced 2024-11-26 21:30:45 +00:00
Handle very large SceRtcTick (#561)
SceDateTime is only documented to support years between 1 and 9999, many SceRtc functions including sceRtcGetTick will fail for years outside of this range. However, SceRtcTick can correspond to very large years.
This commit is contained in:
parent
c5c9399afe
commit
d5d756eeca
16
utils.c
16
utils.c
@ -332,17 +332,33 @@ void getSizeString(char string[16], uint64_t size) {
|
||||
}
|
||||
|
||||
void convertUtcToLocalTime(SceDateTime *time_local, SceDateTime *time_utc) {
|
||||
// sceRtcGetTick and other sceRtc functions fails with year > 9999
|
||||
int year_utc = time_utc->year;
|
||||
int year_delta = year_utc < 9999 ? 0 : year_utc - 9998;
|
||||
time_utc->year -= year_delta;
|
||||
|
||||
SceRtcTick tick;
|
||||
sceRtcGetTick(time_utc, &tick);
|
||||
time_utc->year = year_utc;
|
||||
|
||||
sceRtcConvertUtcToLocalTime(&tick, &tick);
|
||||
sceRtcSetTick(time_local, &tick);
|
||||
time_local->year += year_delta;
|
||||
}
|
||||
|
||||
void convertLocalTimeToUtc(SceDateTime *time_utc, SceDateTime *time_local) {
|
||||
// sceRtcGetTick and other sceRtc functions fails with year > 9999
|
||||
int year_local = time_local->year;
|
||||
int year_delta = year_local < 9999 ? 0 : year_local - 9998;
|
||||
time_local->year -= year_delta;
|
||||
|
||||
SceRtcTick tick;
|
||||
sceRtcGetTick(time_local, &tick);
|
||||
time_local->year = year_local;
|
||||
|
||||
sceRtcConvertLocalTimeToUtc(&tick, &tick);
|
||||
sceRtcSetTick(time_utc, &tick);
|
||||
time_utc->year += year_delta;
|
||||
}
|
||||
|
||||
void getDateString(char string[24], int date_format, SceDateTime *time) {
|
||||
|
Loading…
Reference in New Issue
Block a user