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

后端 未结 5 1109
耶瑟儿~
耶瑟儿~ 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:41

    Parse into what though?

    This will parse into a Hash:

    "4h 30m".split(/\s/).each{|i| h[i.gsub(/\d+/,"")] = i.gsub(/\w/,"")}
    

    Sorry. not familiar with JIRA....

提交回复
热议问题