How to parse a ISO 8601 duration format in Swift?

后端 未结 3 596
夕颜
夕颜 2021-01-24 15:57

I have a function below which I use to format a string. The string is something like this \"PT1H3M20S\" which means 1 hour 3 minutes and 20 seconds. In my function, I want to fo

3条回答
  •  迷失自我
    2021-01-24 16:31

    In your case, your string carries no character for minutes, so you can make a check if the string does not contain minutes, then add "00:" between 1:20 and format appropriately.

提交回复
热议问题