Script to convert dates with ordinal indicators
I have been using the script created originally by Oleh Melnyk and edited by @Manan Joshi from https://community.adobe.com/t5/indesign-discussions/find-and-replace-date-format-indesign-cs6/td-p/13200572 to convert a date format from 09/05/1936 and replace it with 09 May 1936 which works great.
However I would like help to update the script to covert the date format from 09/05/1936 (dd/mm/yyyy or d/m/yyyy) and replace it with Saturday 9th May 1936.
At the moment I use the original script to convert the dates then add the week days manually and then use the following find & replace GREP commands to add the ordinal indicators with the GREP query runner by Peter Kahrel.
Find
(\<02\>)|(\<22\>)
Change to
$0nd
Find
(\<03\>)|(\<23\>)
Change to
$0rd
Find
(\<01\>)|(\<21\>)|(\<31\>)
Change to
$0st
Find
(\<04\>|\<05\>|\<06\>|\<07\>|\<08\>|\<09\>|\<10\>|\<11\>|\<12\>|\<13\>|\<14\>|\<15\>|\<16\>|\<17\>|\<18\>|\<19\>|\<20\>|\<24\>|\<25\>|\<26\>|\<27\>|\<28\>|\<29\>|\<30\>)
Change to
$0th
I think it is possible to use the JavaScript Date getDay() to get the correct weekday?
And I am hoping someone can help update the original script to do these additional steps of adding the correct week day and the ordinal indicators. The original script targets everything in the currently open/active document which is fine and works for most scenarios but I would also like a second version of the updated script that would target text boxes with a specific script label. Script Label = weekday_dates
Any help apreciated.


