Ruby / Rails-将整数转换为星期几 [英] Ruby/Rails - Convert Integer to Day of Week
本文介绍了Ruby / Rails-将整数转换为星期几的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道您可以使用 wday 将星期几作为整数值返回:
I know you can use wday to return the day of the week as an integer value:
Date.new(2001,2,3).wday #=> 6 (a.k.a. "Saturday")
但是,有没有一种方法可以做到这一点呢?逆转?
But, is there a method to do this the opposite way, in reverse?
就像:
day_of_week(6) #=> "Saturday"
或者这是我自己转换的东西吗?
Or is this something I would convert on my own?
谢谢。
推荐答案
Date :: DAYNAMES
数组具有以下信息:
Date::DAYNAMES[6]
# => "Saturday"
这篇关于Ruby / Rails-将整数转换为星期几的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文