extremely weird and frustrating...
Alex Tweedly
alex at tweedly.net
Wed Apr 2 08:27:32 EDT 2014
(answering my own responses again :-)
It depends what your file contains if the time is more than one hour. If
the time was, say, sixty-five-and-a-half minutes, would the file entry
be 65:30 or 1:05:30
If it's the former, then Mark's two-step sort is the right answer.
If it's the latter, then my custom function sort given earlier will work.
If it could be either - then you'd need to extend the custom function;
this will work for either 65:30 or 1:05:30
function hoursMinsSecs pTime
-- change a time in mins:secs to hours:mins:secs
set the itemDel to ":"
if the number of items in pTime = 2 then
put item 1 of pTime into tMins
put tMins div 60 into tHours
put tMins mod 60 into tMins
return tHours & ":" & tMins & ":" & item 2 of pTime
end if
return pTime -- already is hours:mins:secs
end hoursMinsSecs
And if minutes can be negative, then .... that's left as an exercise :-)
-- Alex.
On 02/04/2014 12:04, Alex Tweedly wrote:
>
> I think of 16:33 as sixteen hours and 33 minutes - LC won't interpret
> it as minutes and seconds, and thus anything above 23:59 is invalid -
> and therefore apparently interpreted as "0:00"
>
> Unfortunately I can't find a definitive list of valid formats in the
> docs, but nothing in the dictionary entry for 'convert' includes
> mins:secs - it's always either hours:mins or hours:mins:secs, so I'm
> fairly sure that's what's happening.
>
>
> (You could use a sort by custom function to convert them all to
> hours:min:secs , e.g.
>
> sort field myTimes descending dateTime by hoursMinsSecs(each)
>
> function hoursMinsSecs pTime
> -- change a time in mins:secs to hours:mins:secs
> set the itemDel to ":"
> if the number of items in pTime = 2 then
> return "0:" & pTime
> end if
> return pTime -- already is hours:mins:secs
> end hoursMinsSecs
>
> -- Alex.
>
>
> On 02/04/2014 09:02, larry at significantplanet.org wrote:
>> Sorry Alex, I do not understand.
>>
>> 16:33 is sixteen minutes and 33 seconds.
>> So why is 25:34 not twenty-five minutes and 34 seconds?
>> Last time I checked, there are 60 minutes in an hour.
>>
>> ----- Original Message ----- From: "Alex Tweedly" <alex at tweedly.net>
>> To: <use-livecode at lists.runrev.com>
>> Sent: Wednesday, April 02, 2014 1:59 AM
>> Subject: Re: extremely weird and frustrating...
>>
>>
>>> 25:34 and 34:55 are not valid dateTimes, so where those lines get
>>> sorted to is not well undefined; it looks as though LC simply
>>> decides to give them a '0:00'.
>>>
>>> Apart from those two lines, it looks (to me) like the result is
>>> correct. Isn't it ?
>>>
>>> -- Alex.
>>>
>>>
>>> On 02/04/2014 08:41, larry at significantplanet.org wrote:
>>>> Here is my script line:
>>>> sort field myTimes descending dateTime
>>>>
>>>>
>>>> And here is the result:
>>>> 16:33
>>>>
>>>> 15:56
>>>>
>>>> 12:16
>>>>
>>>> 11:35
>>>>
>>>> 9:14
>>>>
>>>> 7:47
>>>>
>>>> 2:08
>>>>
>>>> 1:22
>>>>
>>>> 25:34
>>>>
>>>> 34:55
>>>>
>>>>
>>>>
>>>> Here is my other script line:
>>>>
>>>> sort field myTimes ascending dateTime
>>>>
>>>> And here is the result for that:
>>>>
>>>> 25:34
>>>>
>>>> 34:55
>>>>
>>>> 1:22
>>>>
>>>> 2:08
>>>>
>>>> 7:47
>>>>
>>>> 9:14
>>>>
>>>> 11:35
>>>>
>>>> 12:16
>>>>
>>>> 15:56
>>>>
>>>> 16:33
>>>>
>>>>
>>>>
>>>> Seriously?
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> use-livecode at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list