Class: NMEAPlus::Message::NMEA::ZDA

Inherits:
NMEAMessage show all
Defined in:
lib/nmea_plus/message/nmea/zda.rb

Overview

ZDA - Time & Date - UTC, day, month, year and local time zone

Instance Attribute Summary collapse

Attributes inherited from NMEAMessage

#message_type, #talker

Attributes inherited from Base

#checksum, #data_type, #fields, #interpreted_data_type, #message_number, #next_part, #original, #payload, #prefix, #total_messages

Method Summary

Methods inherited from NMEAMessage

_10_boolean, _av_boolean

Methods inherited from Base

_float, _hex_to_integer, #_highest_contiguous_index, _integer, _interval_hms, _string, _utc_date_time, _utctime_hms, #add_message_part, #all_checksums_ok?, #all_messages_received?, #calculated_checksum, #checksum_ok?, degrees_minutes_to_decimal, field_reader, #highest_contiguous_index, nsew_signed_float

Instance Attribute Details

#utc_timeTime (readonly)

UTC Time

Returns:

  • (Time)


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/nmea_plus/message/nmea/zda.rb', line 12

def utc_time
  re_format = /(\d{2})(\d{2})(\d{2}(\.\d+)?)/
  hms = re_format.match(@fields[1])
  begin
    tz_h = @fields[5].to_i
    tz = "%s%0.02d:%0.02d" % [tz_h >= 0 ? '+' : '', tz_h, @fields[6].to_i]
    Time.new(@fields[4].to_i, @fields[3].to_i, @fields[2].to_i,
             hms[1].to_i, hms[2].to_i, hms[3].to_f, tz)
  rescue
    nil
  end
end