quad-to-fmt.rb 415 B

12345678910111213141516171819
  1. #!/usr/bin/env ruby
  2. require "date"
  3. require 'tzinfo'
  4. require "time"
  5. datestr = STDIN.gets
  6. puts datestr.chomp
  7. def adjust_time time, time_zone="Asia/Jerusalem"
  8. timestr = TZInfo::Timezone.get(time_zone).utc_to_local(time).to_s
  9. return timestr[0,timestr.length - 3]
  10. end
  11. ms = DateTime.strptime(datestr.chomp,'%Q')
  12. s = DateTime.strptime(datestr.chomp, '%s')
  13. puts "#{adjust_time(s)}\-Ms:#{ms.strftime('%3N')}"