classlib: fix issue with Date.UTC year

Co-authored-by: noblemaster <contact@noblemaster.com>
This commit is contained in:
Christoph Aschwanden 2023-02-12 08:52:36 +01:00 committed by GitHub
parent fdfd923ac6
commit 4fa35e8688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -92,7 +92,7 @@ public class TDate implements TComparable<TDate> {
if (PlatformDetector.isLowLevel()) {
return initUtcDateLowLevel(year, month, date, hrs, min, sec);
} else {
return (long) JSDate.UTC(year, month, date, hrs, min, sec);
return (long) JSDate.UTC(year + 1900, month, date, hrs, min, sec);
}
}

View File

@ -34,4 +34,14 @@ public class DateTest {
assertEquals(4, date.getDate());
assertEquals(115, date.getYear());
}
@SuppressWarnings("deprecation")
@Test
public void setsUTC() {
long epochTime = Date.UTC(2023, 1, 20, 10, 0, 0);
Date date = new Date(epochTime);
assertEquals(2023, date.getYear());
assertEquals(1, date.getMonth());
assertEquals(20, date.getDate());
}
}