mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 02:39:48 -04:00
All the right offsets in all the wrong places. Should fix #1278.
mktime is still borked kinda, but cba to fix that now ._.
This commit is contained in:
parent
b7ae7554fc
commit
f71bf06a59
@ -25,7 +25,7 @@ class OSAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) {
|
||||
else "%d/%m/%y %H:%M:%S"
|
||||
val time =
|
||||
if (lua.getTop > 1 && lua.isNumber(2)) lua.toNumber(2) * 1000 / 60 / 60
|
||||
else machine.worldTime + 5000
|
||||
else machine.worldTime + 6000
|
||||
|
||||
val dt = GameTimeFormatter.parse(time)
|
||||
def fmt(format: String) {
|
||||
|
@ -18,7 +18,7 @@ class OSAPI(owner: LuaJLuaArchitecture) extends LuaJAPI(owner) {
|
||||
else "%d/%m/%y %H:%M:%S"
|
||||
val time =
|
||||
if (args.narg > 1 && args.isnumber(2)) args.todouble(2) * 1000 / 60 / 60
|
||||
else machine.worldTime + 5000
|
||||
else machine.worldTime + 6000
|
||||
|
||||
val dt = GameTimeFormatter.parse(time)
|
||||
def fmt(format: String) = {
|
||||
|
@ -67,8 +67,8 @@ object GameTimeFormatter {
|
||||
def parse(time: Double) = {
|
||||
var day = (time / 24000).toLong
|
||||
val weekDay = ((4 + day) % 7).toInt
|
||||
val year = 1970 + (day / 365.2425).toInt
|
||||
val yearDay = (day % 365.2425).toInt
|
||||
val year = 1970 + (day / 364.2425).toInt
|
||||
val yearDay = (day % 364.2425).toInt
|
||||
day = yearDay
|
||||
val monthLengths = monthLengthsForYear(year)
|
||||
var month = 0
|
||||
@ -80,7 +80,7 @@ object GameTimeFormatter {
|
||||
var seconds = ((time % 24000) * 60 * 60 / 1000).toInt
|
||||
var minutes = seconds / 60
|
||||
seconds = seconds % 60
|
||||
val hours = (1 + minutes / 60) % 24
|
||||
val hours = (minutes / 60) % 24
|
||||
minutes = minutes % 60
|
||||
|
||||
new DateTime(year, month + 1, day.toInt + 1, weekDay + 1, yearDay + 1, hours, minutes, seconds)
|
||||
@ -107,7 +107,6 @@ object GameTimeFormatter {
|
||||
val monthLengths = monthLengthsForYear(year)
|
||||
val days = ((year - 1970) * 365.2425).ceil.toInt + (0 until mon - 1).foldLeft(0)((d, m) => d + monthLengths(m)) + mday - 1
|
||||
val secs = sec + (min + (hour - 1 + days * 24) * 60) * 60
|
||||
if (secs < 0) None
|
||||
else Option(secs)
|
||||
Option(secs)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user