Module: XlsFunction::Converters::TimeSerialConverter
- Defined in:
- lib/xls_function/converters/time_serial_converter.rb
Defined Under Namespace
Classes: TimeSerial
Constant Summary collapse
- H_UNIT =
(BigDecimal('1') / 24)
- M_UNIT =
(H_UNIT / 60)
- S_UNIT =
(M_UNIT / 60)
- MS_UNIT =
(S_UNIT / 1000)
- ORIGIN_TIME =
Time.new(1899, 12, 31, 0, 0, 0).freeze
Class Method Summary collapse
- .serial_to_time(time_serial, now = ORIGIN_TIME) ⇒ Object
- .time_to_serial(time, except_date: false) ⇒ Object
Class Method Details
.serial_to_time(time_serial, now = ORIGIN_TIME) ⇒ Object
23 24 25 |
# File 'lib/xls_function/converters/time_serial_converter.rb', line 23 def serial_to_time(time_serial, now = ORIGIN_TIME) Time.parse(TimeSerial.new(time_serial).to_s, now.to_time) end |
.time_to_serial(time, except_date: false) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/xls_function/converters/time_serial_converter.rb', line 12 def time_to_serial(time, except_date: false) (except_date ? 0 : DateSerialConverter.date_to_serial(time.to_date)) + ( hour_value_of(time) + minute_value_of(time) + second_value_of(time) + millisecond_value_of(time) ).round(15) end |