How to parse days/hours/minutes/seconds in ruby?

后端 未结 5 1104
耶瑟儿~
耶瑟儿~ 2021-02-13 20:55

Is there a gem or something to parse strings like \"4h 30m\" \"1d 4h\" -- sort of like the estimates in JIRA or task planners, maybe, with internationalization?

5条回答
  •  臣服心动
    2021-02-13 21:39

    You can use chronic. It can parse pretty much everything you trhow at it, including "yesterday", "last week" etc.

    Update: As the OP points out in the comment, Chronic is for dates, not timespans. See my other answer.

提交回复
热议问题