MacOS X: recorded time when going to sleep?

Is there a way under MacOS X to tell when the computer last went to sleep?
Martin Frost me at invalid stanford daht edu wrote on :

Is there a way under MacOS X to tell when the computer last went to sleep?

The 'uptime' shell command shows how long the system has been up (including time sleeping, it seems).

And /var/log/system.log records the time of each "System Wake" (but it records "System Sleep" with the actual wakeup time, not the going-to-sleep time).

Martin

Graham Miln replied on :

In article myoe325ged.fsf@redacted.invalid, Martin Frost me at invalid stanford daht edu nospam@redacted.invalid wrote:

Is there a way under MacOS X to tell when the computer last went to sleep?

Our product DssW Sleep Monitor will keep a log of your computer's sleep periods.

Sleep Monitor 2.1 http://www.dssw.co.uk/sleepmonitor/

Alternatively, you need to build a daemon that registers an interest in sleep and wake events.

Power Management for Macintosh; getting started http://developer.apple.com/technotes/tn2002/tn2075.html

Using Cocoa, look for NSWorkspaceWillSleepNotification and NSWorkspaceDidWakeNotification notifications.

Kind regards,

Graham