Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
現在時刻のずれチェックするやつ
#!/usr/bin/env ruby
require 'date'
require 'json'
require 'net/http'
response = Net::HTTP.get URI('http://ntp-a1.nict.go.jp/cgi-bin/json')
json = JSON.parse(response)
diff = json['st'] - Time.now.to_i
if ( diff < -50 || diff > 50 )
p '現在時刻がずれています'
exit 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment