Skip to content
This repository

Fix JS Date format #7

Merged
merged 4 commits into from over 2 years ago

2 participants

Brad Ary Borenszweig
Brad

The format was being printed out in y,d,m when it should be y,m,d. Also, JS months are zero indexed :(

Ary Borenszweig
Owner

Thanks for this!

Instead of the last commit "cast to string first", can't you just interpolate the month? I think interpolation inside interpolation works just fine.

Ary Borenszweig asterite merged commit 4f44053 into from
Ary Borenszweig asterite closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. +4 2 lib/rgviz_rails/executor.rb
6 lib/rgviz_rails/executor.rb
@@ -368,7 +368,8 @@ def value.as_json(options = {})
368 368 self
369 369 end
370 370 def value.encode_json(*)
371   - "new Date(#{strftime('%Y,%d,%m')})"
  371 + month = strftime("%m").to_i - 1
  372 + "new Date(#{strftime('%Y,' + month.to_s + ',%d')})"
372 373 end
373 374 value
374 375 when :datetime
@@ -377,7 +378,8 @@ def value.as_json(*)
377 378 self
378 379 end
379 380 def value.encode_json(*)
380   - "new Date(#{strftime('%Y,%d,%m,%H,%M,%S')})"
  381 + month = strftime("%m").to_i - 1
  382 + "new Date(#{strftime('%Y,' + month.to_s + ',%d,%H,%M,%S')})"
381 383 end
382 384 value
383 385 when :timeofday

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.