Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 设置Date.today以使用Time.zone?_Ruby_Date_Activesupport - Fatal编程技术网

Ruby 设置Date.today以使用Time.zone?

Ruby 设置Date.today以使用Time.zone?,ruby,date,activesupport,Ruby,Date,Activesupport,既然日期。今天使用系统时间,最好的方式是什么 它返回与Time.zone.now.to_date相同的内容,假设Time.zone为 设定 我知道我可以重写Date类,但不确定是否还有其他类 Ruby约定我错过了,因为我肯定我不是第一个这样做的人 遇到此问题。如果设置了时区,将调用时区.today。这是日期的等价物(还有) 还请记住,这些方法都不在Ruby core中,而是由ActiveSupport提供的。请添加一些示例,说明为什么这会令人困惑。

既然
日期。今天
使用系统时间,最好的方式是什么
它返回与
Time.zone.now.to_date
相同的内容,假设
Time.zone
为 设定

我知道我可以重写Date类,但不确定是否还有其他类 Ruby约定我错过了,因为我肯定我不是第一个这样做的人 遇到此问题。

如果设置了
时区,将调用
时区.today
。这是日期的等价物(还有)


还请记住,这些方法都不在Ruby core中,而是由ActiveSupport提供的。

请添加一些示例,说明为什么这会令人困惑。