mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
classlib: fix issue with Date.UTC year
Co-authored-by: noblemaster <contact@noblemaster.com>
This commit is contained in:
parent
fdfd923ac6
commit
4fa35e8688
|
@ -92,7 +92,7 @@ public class TDate implements TComparable<TDate> {
|
||||||
if (PlatformDetector.isLowLevel()) {
|
if (PlatformDetector.isLowLevel()) {
|
||||||
return initUtcDateLowLevel(year, month, date, hrs, min, sec);
|
return initUtcDateLowLevel(year, month, date, hrs, min, sec);
|
||||||
} else {
|
} else {
|
||||||
return (long) JSDate.UTC(year, month, date, hrs, min, sec);
|
return (long) JSDate.UTC(year + 1900, month, date, hrs, min, sec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,4 +34,14 @@ public class DateTest {
|
||||||
assertEquals(4, date.getDate());
|
assertEquals(4, date.getDate());
|
||||||
assertEquals(115, date.getYear());
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user