LoginSignup
19
21

More than 5 years have passed since last update.

次の○曜日の日付を取りたい〜

Posted at

next_weekで出来なかったので、以下みたいにやった。(@tkawa氏に教えてもらった)

Time.current.beginning_of_week(:friday).since(1.week)

2013年9月のカレンダー

1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30

月曜日からみた次の金曜日

Time.parse('2013-09-02').beginning_of_week(:friday).since(1.week)
# => 2013-09-06 00:00:00 +0900

金曜日からみた次の金曜日

Time.parse('2013-09-06').beginning_of_week(:friday).since(1.week)
# => 2013-09-13 00:00:00 +0900

できた〜

19
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
21