Module: Geoptima::FileTime

Defined in:
lib/geoptima/file_time.rb

Constant Summary collapse

DAY_SECONDS =
24 * 60 * 60
DAY_MILLIS =
DAY_SECONDS * 1000
HUNDRED_YEARS_SECONDS =
100 * 365 * DAY_SECONDS
HUNDRED_YEARS_MILLIS =
HUNDRED_YEARS_SECONDS * 1000
@@root =
DateTime.parse("1970-01-01 00:00:00")

Class Method Summary collapse

Class Method Details

.from(time) ⇒ Object



14
15
16
17
18
# File 'lib/geoptima/file_time.rb', line 14

def self.from(time)
  time = time.to_f
  ms = time > HUNDRED_YEARS_SECONDS
  (@@root + time.to_f/(ms ? DAY_MILLIS : DAY_SECONDS))
end

.from_file(arg) ⇒ Object



10
11
12
13
# File 'lib/geoptima/file_time.rb', line 10

def self.from_file(arg)
  base,*times=arg.to_s.split(/_/)
  times.map{|time| self.from(time)}
end