diff --git a/prodos/time.go b/prodos/time.go index f731969..7563825 100644 --- a/prodos/time.go +++ b/prodos/time.go @@ -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]) diff --git a/prodos/time_test.go b/prodos/time_test.go new file mode 100644 index 0000000..66710f2 --- /dev/null +++ b/prodos/time_test.go @@ -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()) + } +}