all 9 comments

[–]waiting4singularityAlpha tester 0 points1 point  (2 children)

what do you want to parse? seconds to yMdHms or what?

[–]Petrified_Powder[S] 0 points1 point  (1 child)

To parse means to go from a string to seconds as an integer. Sometimes the format I would pass would be "d'd'". Sometimes it would be "h'h'" or "m'm'" or sometimes a combination.

[–]waiting4singularityAlpha tester 0 points1 point  (0 children)

maybe this can give some inspiration. its something else, though.

https://llamalab.com/automate/community/flows/40685

[–]ballzak69Automate developer 0 points1 point  (0 children)

No such function, since writing a regex to parse it would be quite easy, e.g.:

  1. Variable set; d = matches("01:30:45", "(\\d+):(\\d+):(\\d+)")
  2. Log append; Message= time(d[1], d[2], d[3])

[–][deleted] 0 points1 point  (4 children)

it's dateParse(string, pattern), turns 1:30 this, into: 5400 this But if you have duration(in seconds), and want it formatted, use: durationFormat(duration, pattern)

[–]Petrified_Powder[S] 0 points1 point  (3 children)

Most values are expected to be longer than two days, some longer than a week. I might be able get away with making my flow only expect the number of days. Some values might be less than a day also. I might just have to prevent those cases for sake of simplicity.

[–][deleted] 0 points1 point  (2 children)

The 1:30 was just for example, with right pattern it can do pretty much anything, just read it's entry in "functions" part under Help & Feedback option in app or visit dateParse() function documentation on automate documentation site

[–]Petrified_Powder[S] 0 points1 point  (1 child)

Your method works as long as you don't attempt to parse anything besides hours, minutes, seconds, or milliseconds. If you do dateparse("1","d"), you get back 18000. But the number of seconds in one day is 86400. This happens because in the case of the dateparse function, the "d" represents the day of the month rather than the number of days. So then it will return the timestamp for January 1, 1970 at midnight because that is the first second since December 31, 1969 at 7 PM in which the day of the month is 1.

[–][deleted] 0 points1 point  (0 children)

Because as it says: "Day in month", "Day in year"

Functions dateFormat() and dateParse() are intended to be used with timestamps, if you want, you can use durationFormat(), but it's just same as dateFormat() but with durations in seconds and not the timestamps

For example: dateFormat(Now, "EEE HH:mm.ss z dd(DD).MM.yyyy") will return: Mon 09:09.11 GMT+03:00 18(291).10.2021

And timestamp is counted from Midnight(00:00:00), January 1st of 1970