Posted to tcl by patthoyts at Tue Jul 10 14:59:24 GMT 2007view raw

  1. # Description:
  2. # Calculate the local offset from GMT in hours for use in the timestamp
  3. #
  4. proc ::smtpd::gmtoffset {} {
  5. set now [clock seconds]
  6. set local [clock format $now -format "%j %H" -gmt false]
  7. set zulu [clock format $now -format "%j %H" -gmt true]
  8. set lh [expr {([scan [lindex $local 0] %d] * 24) \
  9. + [scan [lindex $local 1] %d]}]
  10. set zh [expr {([scan [lindex $zulu 0] %d] * 24) \
  11. + [scan [lindex $zulu 1] %d]}]
  12. set off [expr {$lh - $zh}]
  13. set off [format "%+03d00" $off]
  14. return $off
  15. }