Browse Source

Code commit.

Eliezer Croitoru 3 months ago
parent
commit
b44482b531
2 changed files with 22 additions and 0 deletions
  1. 19 0
      quad-to-fmt.rb
  2. 3 0
      test.sh

+ 19 - 0
quad-to-fmt.rb

@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+
+require "date"
+require 'tzinfo'
+require "time"
+
+datestr = STDIN.gets
+puts datestr.chomp
+
+def adjust_time time, time_zone="Asia/Jerusalem"
+    timestr = TZInfo::Timezone.get(time_zone).utc_to_local(time).to_s
+    return timestr[0,timestr.length - 3]
+end
+
+
+ms =  DateTime.strptime(datestr.chomp,'%Q')
+s = DateTime.strptime(datestr.chomp, '%s')
+
+puts "#{adjust_time(s)}\-Ms:#{ms.strftime('%3N')}"

+ 3 - 0
test.sh

@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+date +"%s%N" |ruby quad-to-fmt.rb