Last active
May 2, 2024 11:32
-
-
Save yuya-maemichi-synspective/af666a8ddcad04750e2bc8f07a11355f to your computer and use it in GitHub Desktop.
Ruby snippets
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
y = 2024 | |
t0 = Time.new(y) | |
year_seconds = Time.new(y + 1) - t0 | |
c = 100 | |
c.times.map { t0 + (year_seconds / c * _1) } |
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
y = 2024 | |
d0 = Time.new(y) | |
d1 = Time.new(y+1) | |
year_seconds = d1.to_time - d0.to_time | |
(d0...d1).map{ ((_1.to_time - d0.to_time) / year_seconds) }.each{ printf "%.3f\n", _1 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment