mirror of
https://github.com/tjboldt/ProDOS-Utilities.git
synced 2024-11-28 12:51:35 +00:00
Fix date calculation bug and add test
This commit is contained in:
parent
77f8ee59a0
commit
e802ee7ceb
@ -45,7 +45,7 @@ func DateTimeFromProDOS(buffer []byte) time.Time {
|
|||||||
}
|
}
|
||||||
|
|
||||||
month := int(buffer[0]>>5 + buffer[1]&1)
|
month := int(buffer[0]>>5 + buffer[1]&1)
|
||||||
day := int(buffer[0] & 23)
|
day := int(buffer[0] & 31)
|
||||||
hour := int(buffer[3])
|
hour := int(buffer[3])
|
||||||
minute := int(buffer[2])
|
minute := int(buffer[2])
|
||||||
|
|
||||||
|
15
prodos/time_test.go
Normal file
15
prodos/time_test.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package prodos
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDateTimeToAndFromProDOS(t *testing.T) {
|
||||||
|
now := time.Now().Round(time.Minute)
|
||||||
|
|
||||||
|
got := DateTimeFromProDOS(DateTimeToProDOS(now))
|
||||||
|
if got != now {
|
||||||
|
t.Errorf("DateTimeFromProDOS(DateTimeToProDOS(now)) = %s; want %s", got.String(), now.String())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user