manipulating date in applescript

31 views
Skip to first unread message

spuddybike

unread,
Mar 20, 2012, 6:29:58 AM3/20/12
to GEDitCOM II Discussions

I would like to remove day of birth from the public website, not just
splat everything with Privacy
The function GetTextForEvent grabs the date from "event date user"

on GetTextForEvent(theRec, theTag, everb, pref, h3Text)
tell application "GEDitCOM II"
-- look for for the structure
tell theRec
set evnts to find structures tag theTag output "references"
set numEvnt to number of items in evnts
if numEvnt = 0 then
return ""
end if
if h3Text = "" then
set numEvnt to 1
end if
end tell

-- one is found, so process it
set edall to ""
repeat with i from 1 to numEvnt
set evnt to item i of evnts
set ed to ""
tell evnt
-- the date
set edate to event date user
if edate is not "" then
set ed to HeSheNow & " " & everb & " " & edate
end if

I'd like to pass to edate just the month and year, so I suppose I
should use the rightString method
something like
-- the date
set eyear to rightString(edate, " ")
set edaymonth to
leftStringFromRight(edate, " ")
set emonth to leftString(edaymonth," ")
set emonthyear to month & " " & eyear
if edate is not "" then
set ed to HeSheNow & " " & everb & " " & emonthyear
end if

But I get the following error

structure 3 of individual id "@I655@" of document "O'Hara and
Stuart.gedpkg" doesn’t understand the rightString message
any ideas?

thanks
Jon

John Nairn

unread,
Mar 27, 2012, 12:05:49 AM3/27/12
to geditcom-ii...@googlegroups.com
> I'd like to pass to edate just the month and year, so I suppose I
> should use the rightString method
> something like
> -- the date
> set eyear to rightString(edate, " ")
> set edaymonth to leftStringFromRight(edate, " ")
> set emonth to leftString(edaymonth," ")
> set emonthyear to month & " " & eyear
> if edate is not "" then
> set ed to HeSheNow & " " & everb & " " & emonthyear
> end if
>
> But I get the following error
>
> structure 3 of individual id "@I655@" of document "O'Hara and
> Stuart.gedpkg" doesn’t understand the rightString message
> any ideas?
>
> thanks
> Jon

I am not sure what rightString() (etc.) are? I don't think it is a defined function in AppleScript? You could write one and call it, but otherwise I cannot tell what you want to do.

You mentioned getting just month and year. Rather then try to decode the date string (which will need to handle lots of special cases), the much better approach is to reformat the date using a custom scripting command for GEDitCOM II such as

date style full date edate with format "%M %y"

which will reformat any date using just month and year. For example input "JUL 1776" would outlut "JUL 1776" as I think you want. The format supplied need not include all parts of the date.

These and many other date commands are described inthe "Scripting Command" section on the "Scripting Features" chapter of the GEDitCOM II help.

John

------------
John Nairn
http://www.geditcom.com
Genealogy Software for the Mac

Reply all
Reply to author
Forward
0 new messages