Module: Evesync::NTP

Defined in:
lib/evesync/ntp.rb

Class Method Summary collapse

Class Method Details

.timeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/evesync/ntp.rb', line 8

def self.time
  begin
    Timeout.timeout(5) do
      Net::NTP.get(Config['ntp']).time
    end
  rescue Errno::ECONNREFUSED
    Log.warn('NTP not configured. Using local time for timestamps')
    Time.now
  rescue Timeout::Error
    Log.warn('NTP timeout. Using local time')
    Time.now
  end
end

.timestampObject



22
23
24
# File 'lib/evesync/ntp.rb', line 22

def self.timestamp
  time.to_f.to_s
end