Last active
December 24, 2018 15:37
-
-
Save hanachin/f2194b75e296b24592bb36b60f31cc6d to your computer and use it in GitHub Desktop.
Re: 10分間隔で 10時〜23時台の配列をつくる ref: https://qiita.com/hanachin_/items/1a7b9ea0af62e5021c94
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
("10:00".."23:50").step(10).select {|t| t.match?(/:[0-5]0/) } |
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
(1000..2350).step(10).select {|t| t % 100 < 60 }.map(&:to_s).each {|s| s[2,0] = ?: } |
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
("10".."23").to_a.product(("00".."50").step(10).to_a).map {|t| t.join(?:) } |
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
("10".."23").flat_map {|h| ("00".."50").step(10).map {|m| "#{h}:#{m}" } } |
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
Time.new(0, 1, 1, 10, 0).then {|t| loop.lazy.map { t.tap { t += 10 * 60 } }.take_while {|t| t <= Time.new(0, 1, 1, 23, | |
50) }.map {|t| t.strftime("%H:%M") }.to_a } |
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
Enumerator.new {|y| t = Time.new(0, 1, 1, 10, 0); while t <= Time.new(0, 1, 1, 23, 50); y << t.strftime("%H:%M"); t +=10 * 60; end }.to_a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment