Saying the time in Leopard

In Leopard, if you use the say command for the time and the time is written with a colon, the time will spoken using a 12-hour clock with the suffix. Try this in Leopard:

say "16:45"

However, if you use a space, the time will be spoken using a 24-hour clock.

I do not know why Apple did this but with such an easy go-around there’s no need to submit a bug report.

Model: MacBook
AppleScript: 2.2
Browser: Safari 523.10
Operating System: Mac OS X (10.5)

That quite interesting.

That quit interesting.

say "16:45:10"

→ sixteen hours forty five minutes ten seconds

say "1,645"

–>one thousand six hundread and forty five

Anyone got a better way of saying a number rather than a time?

That’s interesting. Does it depend on the user’s Date and Time preferences? That is: are your own preferences set to use a twelve-hour clock? And if so, is the script’s effect different if you use a twenty-four hour clock instead?

The clock preference setting does not seem to matter. I have mine set to 24-hour, and I get the same results:

say "16:45"

yields "Four Forty-Five P.M. and:

say "16:45:10"

yields “Sixteen hours, Forty-Five minutes, Ten seconds.”

The behaviours are the same with Preferences set either way.

Hmm. Thanks, Craig. Unless there’s a new parameter for the ‘say’ command, it’s probably a bug caused by someone at Apple trying to be too clever. :confused:

G’day

I use the following format to get the real time…


tell application "Finder"
	say (current date) as string
	set temp to (current date)
	set totalseconds to time of temp
	set temphours to totalseconds div 3600
	set tempminutes to (totalseconds - (temphours * 3600)) div 60
	set tempseconds to totalseconds - (temphours * 3600) - (tempminutes * 60)
	delay 3
	
        --- 24 hour clock
	set tempspeech to temphours & " " & tempminutes & " and" & tempseconds & " seconds" as string
	say tempspeech
	delay 3
	
	--- 24 hour clock
	set tempspeech to temphours & ":" & tempminutes & ":" & tempseconds as string
	say tempspeech
	delay 3
	
	--- 12 hour clock
	set AMorPM to "AM"
	if temphours > 11 then
		set temphours to temphours - 12
		set AMorPM to "PM"
	end if
	if temphours = 0 then set temphours to 12
	set tempspeech to temphours & " " & tempminutes & " and" & tempseconds & " seconds " & AMorPM as string
	say tempspeech
	
end tell

Santa

Model: intel iMac
AppleScript: 2.1.1
Browser: Safari 3.0.4
Operating System: Mac OS X (10.5)

There aren’t any new parameters. (I just installed Leopard last night. :D)

Hi Santa,

the Finder is not needed at all in your script.

btw, this:


say (current date) as string
set temp to (current date)
set totalseconds to time of temp
set temphours to totalseconds div 3600
set tempminutes to (totalseconds - (temphours * 3600)) div 60
set tempseconds to totalseconds - (temphours * 3600) - (tempminutes * 60)

is the same as:

tell (current date) to set {temp, temphours, tempminutes, tempseconds} to {it as text, its hours, its minutes, its seconds}
say temp

:wink: