Created
January 8, 2014 14:45
-
-
Save ysugimoto/8317861 to your computer and use it in GitHub Desktop.
現在時刻のずれチェックするやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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