Fix date calculation bug and add test

This commit is contained in:
Terence Boldt 2021-06-27 22:30:33 -04:00
parent 77f8ee59a0
commit e802ee7ceb
2 changed files with 16 additions and 1 deletions

View File

@ -45,7 +45,7 @@ func DateTimeFromProDOS(buffer []byte) time.Time {
}
month := int(buffer[0]>>5 + buffer[1]&1)
day := int(buffer[0] & 23)
day := int(buffer[0] & 31)
hour := int(buffer[3])
minute := int(buffer[2])

15
prodos/time_test.go Normal file
View 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())
}
}