Method: Origami::Date#initialize
- Defined in:
- lib/origami/string.rb
#initialize(year:, month: 1, day: 1, hour: 0, min: 0, sec: 0, utc_offset: 0) ⇒ Date
Returns a new instance of Date.
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/origami/string.rb', line 373 def initialize(year:, month: 1, day: 1, hour: 0, min: 0, sec: 0, utc_offset: 0) @year, @month, @day, @hour, @min, @sec = year, month, day, hour, min, sec @utc_offset = utc_offset date = "D:%04d%02d%02d%02d%02d%02d" % [year, month, day, hour, min, sec ] if utc_offset == 0 date << "Z00'00" else date << (if utc_offset < 0 then '-' else '+' end) off_hours, off_secs = utc_offset.abs.divmod(3600) off_mins = off_secs / 60 date << "%02d'%02d" % [ off_hours, off_mins ] end super(date) end |