当我使用英语时,我的日期可以正常工作。
> Date.strptime("Aug 02, 2015", "%b %d, %Y")
Sun, 02 Aug 2015
然而,当我使用另一种语言
es
时,它就无法工作了。例如:> Date.strptime("ago 02, 2015", "%b %d, %Y")
ArgumentError: invalid date
ago 02, 2015
这个文本字符串来自另一个服务,我需要将其标准化为特定的格式,例如
> I18n.localize(Date.strptime("Aug 02, 2015", "%b %d, %Y"), format: "%m/%d/%Y")
"08/02/2015"
有没有一种在Ruby中实现这个的方法,以便...
> I18n.localize(Date.strptime("ago 02, 2015", "%b %d, %Y"), format: "%m/%d/%Y")
"08/02/2015"