Hi Val,
Re your questions 3 & 4: I’m almost done rewriting a rather lengthy Pashua script which ran fine in Tiger, but less so in Snow Leopard.
The script had 2 problems when it moved to Snow Leopard.
-
Pashua is summer/wintertime [DST] aware, which I did not understand at the time. This becomes a problem when you save dates from Pashua into a file, and then reopen the file at the other side of a DST “boundary”.
In winter, I get “2010-01-01 00:00:00 +0100” (Netherlands)
In sommer, I get "“2010-06-14 11:46:21 +0200”
Get Pashua dates like so:
do shell script "date '+%F %X %z'"-- the %z adds the time zone as time difference from UTC
My solution: convert Pashua dates to date objects immediately; convert them back before passing them to Pashua. Also store them as date objects.
-
A date which was changed in a Pashua window now comes back in a different format:
“donderdag 15 juli 2010 07:00:00 Nederland-tijd”,
which is not something I have in System Preferences.
Luckily, this smoothly converts to a date object:
date “donderdag 15 juli 2010 07:00:00 Nederland-tijd” → “donderdag 15 juli 2010 7:00”.
So I added a test to my date conversion routine to deal with this.
Here are my routines:
-----------------------------------------------------------------------
-- Convert a date object to a Pashua date string
-- allows for summer/winter time
-- should work with any system date format
-- parameter: date object
-- returns: Pashua date string
-----------------------------------------------------------------------
on convertDateObjectToPashuaDate(dateObject)
tell dateObject to set {d, m, y} to {it's day, it's month as integer, it's year}
set timeStr to time string of dateObject
-- create Pashua style date string
set text item delimiters to "-"
set dateStr to {y, m, d} as string
set text item delimiters to ""
-- create the Pashua date; shell command adds time zone incl DST
set dateStr to dateStr & " " & timeStr & " " & (do shell script "date '+%z'") -- see manpage for strftime
return dateStr
end convertDateObjectToPashuaDate
-----------------------------------------------------------------------------------
-- Convert a Pashua date string to a date object
-- assumes dd-mm-yyyy order for the system date
-- Pashua returns a changed date in the system's full format
-- so there's no error
-- an unchanged date comes back in UTC format
-- which triggers an error, and it's dealt with as text
-- parameter: Pashua date string
-- returns: AppleScript date object
-----------------------------------------------------------------------------------
on convertPashuaDateToDateObject(pashuaDate)
try
return date pashuaDate -- when it was changed
on error
set text item delimiters to " "
set theDate to text item 1 of pashuaDate
set timeStr to text item 2 of pashuaDate
set text item delimiters to "-"
set yyyy to text item 1 of theDate
set MM to text item 2 of theDate
set DD to text item 3 of theDate
set dateStr to {DD, MM, yyyy} as string
set text item delimiters to ""
return date (dateStr & " " & timeStr)
end try
end convertPashuaDateToDateObject
(I would like to thank all of you scriptmasters that helped me -unknowingly- to solve my dating problems : )
There’s room for improvement, I’m sure…
Thijs