Ruby Time.parse让我超出范围错误 [英] Ruby Time.parse gives me out of range error

查看:136
本文介绍了Ruby Time.parse让我超出范围错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Time.parse从字符串创建一个Time对象。



由于某些原因

  Time.parse(05-14-2009 19:00)

引起范围误差的参数,而

  Time.parse(05-07-2009 19:00 )



任何想法

解决方案

我的猜测是,它期望字符串的第二部分(14)成为这个月。 p>

此链接可能有助于您解析。 a>


I am using Time.parse to create a Time object from a string.

For some reason

Time.parse("05-14-2009 19:00")

causes an argument our of range error, whereas

Time.parse("05-07-2009 19:00")

does not

Any ideas?

解决方案

My guess would be that its expecting the second part of the string (the 14) to be the month.

This link may help you parse it.

这篇关于Ruby Time.parse让我超出范围错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆