Class: M2TSParser::Appendix::AribTime
- Inherits:
-
BinaryParser::TemplateBase
- Object
- BinaryParser::TemplateBase
- M2TSParser::Appendix::AribTime
- Defined in:
- lib/m2ts_parser/appendix/arib_time.rb
Instance Method Summary collapse
- #content_description ⇒ Object
-
#convert_mjd_to_date(mjd) ⇒ Object
ARIB STD-B10 2, appendix-C.
- #date ⇒ Object
- #date_str ⇒ Object
- #to_s ⇒ Object
- #to_time ⇒ Object
Instance Method Details
#content_description ⇒ Object
41 42 43 |
# File 'lib/m2ts_parser/appendix/arib_time.rb', line 41 def content_description to_s end |
#convert_mjd_to_date(mjd) ⇒ Object
ARIB STD-B10 2, appendix-C
19 20 21 22 23 24 25 26 27 |
# File 'lib/m2ts_parser/appendix/arib_time.rb', line 19 def convert_mjd_to_date(mjd) y_ = ((mjd - 15078.2) / 365.25).to_i m_ = ((mjd - 14956.1 - (y_ * 365.25).to_i) / 30.6001).to_i d = mjd - 14956 - (y_ * 365.25).to_i - (m_ * 30.6001).to_i k = (m_ == 14 || m_ == 15) ? 1 : 0 y = y_ + k m = m_ - 1 - k * 12 return Date.new(1900 + y, m, d) end |
#date ⇒ Object
14 15 16 |
# File 'lib/m2ts_parser/appendix/arib_time.rb', line 14 def date return @date ||= convert_mjd_to_date(mjd.to_i) end |
#date_str ⇒ Object
29 30 31 |
# File 'lib/m2ts_parser/appendix/arib_time.rb', line 29 def date_str return sprintf("%02d/%02d/%02d", date.year, date.month, date.day) end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/m2ts_parser/appendix/arib_time.rb', line 33 def to_s return sprintf("%s %02d:%02d:%02d +0900", date_str, hour.to_i, min.to_i, sec.to_i) end |
#to_time ⇒ Object
37 38 39 |
# File 'lib/m2ts_parser/appendix/arib_time.rb', line 37 def to_time return Time.parse(to_s) end |