How can I get the local string for Monday?
I know how to get the ‘date string’, but in some countries, the weekday is not going to be the first word of that string.
Is there some syntax to get the ‘weekday string’ of a date?
How can I get the local string for Monday?
I know how to get the ‘date string’, but in some countries, the weekday is not going to be the first word of that string.
Is there some syntax to get the ‘weekday string’ of a date?
Does this work?
weekday of (current date)
– Rob
rob,
weekday of (current date)
returns the non-string weekday. these seem to always be in english. so the following always returns the english weeksday, no matter what the local settings are:
weekday of (current date) as string
the following the date in the local language:
date string of (current date)
but it doesn’t parse the weekday. the weekday is usually the first word in that date string, but not always.
i’m also looking for some way to find the local short weekday - in the USA it’s always 3 characters i.e “Mon”, but this varies worldwide.
Petey,
If you’d like, I’ll send dateLib, by HAS (his web site full of AppleScript gems has disappeared, but I snagged a few libraries before it vanished). There’s a good chance that dateLib includes the info that you need.
Description: Handlers for converting dates to “dd/mm/yy”-style formatted strings and vice-versa, with support for multiple languages.
It’s very well documented.
– Rob (who isn’t smart about dates and non-English systems)
Hi pety and Rob
I do not know if you already found a solution, but here what have just found.
It is a question of using the information contained in the preferences system of the user, here the code:
on clicked theObject
set defaultDateFormat to contents of default entry "NSDateFormatString" of user defaults
--> English version = "%A, %B %e, %Y"
--> French version = "%A %e %B %Y"
--"%A" = weekday
--"%e" = day
--"%B" = month
--"%Y" = year
set text item delimiters of AppleScript to " "
set ListDateFormat to text items of defaultDateFormat
set text item delimiters of AppleScript to ""
repeat with Loop from 1 to (length of ListDateFormat)
if "%A" is in (contents of item Loop of ListDateFormat) then exit repeat
end repeat
set DateString to date string of (current date)
set TheWeekDay to word Loop of DateString
display dialog TheWeekDay with icon 1
end clicked
Fredo,
Thank you. Merci. Danke. Gracias.
i can localize my app’s date info now.
all the goodies that i never would have found without you are documented at: