Skip to content

Fix protocol 6 (Beepwear Pro) setting time 1 hour fast in daylight savings time #314

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

Merged
merged 1 commit into from
Jul 27, 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
18 changes: 7 additions & 11 deletions lib/timex_datalink_client/protocol_6/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,23 @@ def cpacket
end

def second
flex_time ? 0 : formatted_time.sec
flex_time ? 0 : time.sec
end

def hour
flex_time ? 0 : formatted_time.hour
flex_time ? 0 : time.hour
end

def minute
flex_time ? 0 : formatted_time.min
flex_time ? 0 : time.min
end

def month
flex_time ? 0 : formatted_time.month
flex_time ? 0 : time.month
end

def day
flex_time ? 0 : formatted_time.day
flex_time ? 0 : time.day
end

def formatted_name
Expand All @@ -169,15 +169,11 @@ def name_characters
end

def year_mod_1900
flex_time ? 0 : formatted_time.year % 100
flex_time ? 0 : time.year % 100
end

def wday_from_monday
flex_time ? 0 : (formatted_time.wday + 6) % 7
end

def formatted_time
time.dst? ? time + 3600 : time
flex_time ? 0 : (time.wday + 6) % 7
end

def formatted_utc_offset
Expand Down
9 changes: 0 additions & 9 deletions spec/lib/timex_datalink_client/protocol_6/time_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,6 @@
]
end

context "when time is in daylight savings time" do
let(:tzinfo) { TZInfo::Timezone.get("US/Pacific") }
let(:time) { tzinfo.local_time(2015, 10, 21, 19, 28, 32) }

it_behaves_like "CRC-wrapped packets", [
[0x32, 0x01, 0x20, 0x14, 0x1c, 0x0a, 0x15, 0x0f, 0x1a, 0x0e, 0x1e, 0x02, 0x18, 0x01, 0x00]
]
end

context "when time has a UTC offset of -11:00" do
let(:utc_offset) { "-11:00" }

Expand Down