More sync errors - suspect date localisation

2 views
Skip to first unread message

nigelm

unread,
Mar 28, 2008, 5:49:48 AM3/28/08
to OFTD
Running the b26 version, I am still seeing this sort of error:-

AppleScript reported the following error:
Invalid date and time 03-27-2008 16:05:38.

when items have been changed/updated/created within Toodledo

For me, in the UK locale, 03-27-2008 is not a valid date, so I am
wondering
if that is whats causing the problem.

Nigel.

nigelm

unread,
Mar 28, 2008, 10:55:42 AM3/28/08
to OFTD
Definitely looks to me as though localisation is the problem.

So, having never played with AppleScript before (so be gentle in the
comments!), I tried changing the parsing function to this:-

on TDTimeStampToASDate(dateStr, applyOffset)
-- 2008-01-09 18:53:15
-- or 2008-03-29 11:59 pm
-- or 2008-03-29
set unAdjusted to current date -- where we start
set year of unAdjusted to (text 1 thru 4 of dateStr)
set month of unAdjusted to (text 6 thru 7 of dateStr)
set day of unAdjusted to (text 9 thru 10 of dateStr)
if length of dateStr ≥ 19 then
if text 18 thru 19 of dateStr = "pm" then
set time of unAdjusted to (((text 12 thru 13 of dateStr) * hours) +
((text 15 thru 16 of dateStr) * minutes) + (12 * hours))
else
set time of unAdjusted to (((text 12 thru 13 of dateStr) * hours) +
((text 15 thru 16 of dateStr) * minutes))
end if
else
set time of unAdjusted to 0
end if

if not applyOffset then
return unAdjusted
else
if (hours of unAdjusted) + (minutes of unAdjusted) = 0 then --no
time was set, don't adjust
return unAdjusted
else
return (unAdjusted + (timeOffset * hours))
end if
end if
end TDTimeStampToASDate


Additionally I needed modify this fragment in TDTask2OFTask (I pushed
the date through the parser rather than converting it in place)

set dateStr to TDcompleted of TaskData
--set mvTest to (item (TD_taskKey's TD_completed) of TaskData)
if dateStr is not false then
set completionDate to my TDTimeStampToASDate(dateStr, false)
set completed of thisTask to true
set completion date of thisTask to completionDate
else
set completed of thisTask to false
end if
set TDpriority to TDpriority of TaskData as number
if TDpriority is greater than 0 then
set flagged of thisTask to true
else
set flagged of thisTask to false
end if

Seems to work for me now....

Preston Holmes

unread,
Mar 28, 2008, 1:03:53 PM3/28/08
to of...@googlegroups.com
Great I'll try and roll these in at some point and add a pref for date
format.

The Tiger compatibility will be harder to do...

I had noted both of these limitations on the OFTD group welcome page
earlier in the week.

-Preston

Reply all
Reply to author
Forward
0 new messages