« Return to Thread: Does Such A Tag Already Exist?

Re: Does Such A Tag Already Exist?

by Jason Huck :: Rate this Message:

Reply to Author | View in Thread

This would work with any order, but would need to be space-delimited:

define_tag('string_toduration', -req='in');
    local('d' = 0, 'h' = 0, 'm' = 0, 's' = 0);
    iterate(#in->split(' '), local('i'));
        local('u') = string(#i)->removeleading(integer(#i))&;
        local(#u) = integer(#i);
    /iterate;
    return(duration( -day=#d, -hour=#h, -minute=#m, -second=#s));
/define_tag;

string_toduration('1d 17h 45m 22s');


- jason



On Tue, Jun 30, 2009 at 1:52 PM, Brad Lindsay<blindsay@...> wrote:

>
> On Jun 30, 2009, at 1:44 PM, Steve Piercy - Web Site Builder wrote:
>>
>> I don't think it exists yet.  If you create one, please do post it to
>> tagswap.net.
>
> I definitely will.
>
>
>> I would start off by taking the string, '1d 17h 45m 22s', split on space,
>> then parse each element in the resulting array.
>
> I was thinking of starting by removing the spaces - making them optional.
>  However, do you think I should enforce the logical order?  In other words,
> should you have to put minutes before seconds, or should you be able to
> reference them in any order? (I'm leaning towards allowing them to be
> specified in any order)
>
> -Brad
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>
>



--
tagSwap.net :: Open Source Lasso Code
<http://tagSwap.net/>

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


 « Return to Thread: Does Such A Tag Already Exist?