Jump to content

Date Manipulation/ Convert Time Format fails for ISO -> UNIX

Recommended Posts

I'm making a workflow that converts timestamp to ISO and vice versa. Timestamp to ISO format works, but the following object fails converting from ISO to unix timestamp:




The error is:


[17:14:50.964] time[Conditional] Processing complete
[17:14:50.966] time[Conditional] Passing output ' 1969-12-31T16:33:44-0800' to Automation Task
[17:14:50.967] time[Automation Task] Running task 'Convert Time Format' with arguments (
    " 1969-12-31T16:33:44-0800"
[17:14:50.974] STDERR: time[Automation Task] Warning: Ignoring 20 extraneous characters in date string (-12-31T16:33:44-0800)

It seems to ignore anything that is not a number.

Here's the entire workflow FWIW:



Link to comment
Posted (edited)

I just realized that an issue with the regex in the conditional is making it use the unix -> iso branch.


However, there's still a discrepancy between how the ISO->timestamp vs timestamp->ISO work. The leading whitespace from the conditional causes issues for the date parsing:



[17:43:07.735] time[Conditional] Passing output ' 1969-12-31T16:33:44' to Automation Task
[17:43:07.736] time[Automation Task] Running task 'Convert Time Format' with arguments (
    " 1969-12-31T16:33:44"
[17:43:07.746] STDERR: time[Automation Task] Failed conversion of `` 1969-12-31T16:33:44'' using format ``%FT%T%z''
date: illegal time format
usage: date [-jnRu] [-I[date|hours|minutes|seconds]] [-f input_fmt]
            [-r filename|seconds] [-v[+|-]val[y|m|w|d|H|M|S]]
            [[[[mm]dd]HH]MM[[cc]yy][.SS] | new_date] [+output_fmt]
[17:43:07.747] time[Automation Task] Processing complete


I added another task automation for "Trim Line Whitespace" right before and now it's working :)

Since the leading whitespace is not an issue for the opposite (timestamp->ISO) should Alfred trim the whitespace rather than requiring another automation task to do it?

Edited by ora
add additional info about discrepancy between unix/ISO
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...