--- autoaway.tcl.orig	2005-03-14 00:14:21.000000000 +0300
+++ autoaway.tcl	2006-07-06 18:49:08.273342100 +0400
@@ -5,6 +5,7 @@
     variable savestatus ""
     variable savetext   ""
     variable savepriority 0
+	variable away_since 0
 }
 
 
@@ -62,6 +63,14 @@
 	[::msgcat::mc "Set priority to 0 when moving to extended away state."] \
 	-group AutoAway -type boolean
 
+	custom::defvar options(time_format) "" \
+	[::msgcat::mc "Time format as of \[clock format\]."] \
+	-group AutoAway -type string
+
+	custom::defvar options(time_is_gmt) 0 \
+	[::msgcat::mc "Format time as GMT."] \
+	-group AutoAway -type boolean
+
     hook::add connected_hook    [namespace current]::after_idle
     hook::add disconnected_hook [namespace current]::after_idle_cancel
 }
@@ -89,6 +98,7 @@
     variable savestatus
     variable savetext
     variable savepriority
+	variable away_since
     global idle_command
     global userstatus textstatus
     global userpriority
@@ -116,10 +126,11 @@
     switch -- $userstatus {
         available -
         chat {
+			set away_since [clock seconds]
             set savestatus $userstatus
 	    set savetext $textstatus
 	    set savepriority $userpriority
-            set textstatus $options(status)
+            set textstatus [subst_status $options(status)]
             if {$idletime >= [expr {$options(xatime)*60*1000}]} {
 		if {$options(drop_priority) && ($userpriority >= 0)} {
 		    set userpriority 0
@@ -137,7 +148,7 @@
             if {(![cequal $savestatus ""]) && \
 		    ($idletime >= [expr {$options(xatime)*60*1000}])} {
 		set savepriority $userpriority
-		set textstatus $options(status)
+		set textstatus [subst_status $options(status)]
 		if {$options(drop_priority) && ($userpriority >= 0)} {
 		    set userpriority 0
 		}
@@ -164,5 +175,16 @@
                  $line] 1]"/1000000}
 }
 
+proc autoaway::subst_status {status} {
+	variable options
+	variable away_since
+	set cmd [list clock format $away_since]
+	if {$options(time_format) != ""} {
+		lappend cmd -format $options(time_format)
+	}
+	lappend cmd -gmt $options(time_is_gmt)
+	regsub -all %T $status [eval $cmd]
+}
+
 autoaway::load
 
