Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: encode DST to NAS will mistake "+10:45" for having DST #23

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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