Skip to content

Commit

Permalink
Fix bug: encode DST to NAS will mistake "+10:45" for having DST (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
YouShengLiu authored Oct 30, 2023
1 parent 397cea6 commit 1cac52d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nasConvert/Time.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ func EncodeDaylightSavingTimeToNas(
var nasDaylightSavingTime nasType.NetworkDaylightSavingTime

value := 0
if strings.Contains(timezone, "+1") {
if timezone[len(timezone)-2:] == "+1" {
value = 1
}
if strings.Contains(timezone, "+2") {
if timezone[len(timezone)-2:] == "+2" {
value = 2
}

Expand Down
7 changes: 7 additions & 0 deletions nasConvert/Time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ func TestDaylightSavingTimeToNas(t *testing.T) {
Octet: uint8(0x00),
},
},
{
in: nasConvert.EncodeDaylightSavingTimeToNas("+10:45"),
out: nasType.NetworkDaylightSavingTime{
Len: uint8(0x01),
Octet: uint8(0x00),
},
},
}

for _, tc := range nasConvertNetworkDaylightSavingTimeTable {
Expand Down

0 comments on commit 1cac52d

Please sign in to comment.