Jump to content

Turn an abbreviated date into a real date


Nd_

Recommended Posts

Is there a way to turn an abbreviated date into a date. I thought something like if last character of arg-2 is "d", but I realized that this wouldn't work with more complicated abbreviated dates, like 7d5h3m1s. Is there a way to do this? 

Link to comment
Share on other sites

You can use this function:

function toTimespan(t: text) :: timespan:
    set {_conversion::s} to "seconds"
    set {_conversion::m} to "minutes"
    set {_conversion::h} to "hours"
    set {_conversion::d} to "days"
    set {_l} to length of {_t}
    set {_a} to {_l} - 1
    set {_l::1} to first {_a} characters of {_t}
    set {_l::2} to last character of {_t}
    set {_t} to "%{_l::1}% %{_conversion::%{_l::2}%}%"
    return ({_t} parsed as timespan)

 

It isn't perfect but it should do the job.

[VIP] 2019

[JR.MOD] 10/29/2019

[MOD] 12/30/2019

nerd3.png

ok.png

sure.png

q.png

Link to comment
Share on other sites

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...