Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issue with CT to CST/CDT TZ conversion to GMT.

Status
Not open for further replies.

GopiChand9

Technical User
Apr 14, 2004
1
CH
Hi,

I recived the datetime format in CT timezone. Since the OS TZ is CST or CDT I need to convert CT to CST/CDT and then I will conver the datetime format to GMT at different daylight saving time.

I am following this method. But I am not happy. If some one has good solution please forward me.

---
set createDate "10/20/2003 00:56:00 CT"
set extTrxGMTDate [dt2DesyDateTimeGMT $createDate]
elog INFO "DEBUG -- > $extTrxGMTDate"

proc dt2DesyDateTimeGMT { d } {

if { [string length $d] == 0 } { return "" }

set agmtdate [clock format [clock seconds] -gmt 1]
elog INFO "DEBUG -- > $agmtdate"
set agmttdate [clock scan $agmtdate -gmt 1]
elog INFO "DEBUG -- > $agmttdate"
set agmtttdate [clock format $agmttdate -format "\%Y\%m\%d\%H" -gmt 1]
elog INFO "DEBUG -- > $agmtttdate"

set bgmtdate [clock format [clock seconds]]
elog INFO "DEBUG -- > $bgmtdate"
set bgmttdate [clock scan $bgmtdate]
elog INFO "DEBUG -- > $bgmttdate"
set bgmtttdate [clock format $bgmttdate -format "\%Y\%m\%d\%H"]
elog INFO "DEBUG -- > $bgmtttdate"

set finalGMTDate [expr $agmtttdate - $bgmtttdate]
elog INFO "DEBUG -- > $finalGMTDate"

if { $finalGMTDate == -1 } {
regsub CT $d CST dm
} else {
regsub CT $d CDT dm
}

set dd [string range $dm 0 22]
set ddi [clock scan $dd -gmt 1]
return [clock format $ddi -format "\%Y\%m\%d \%H\%M\%S00" -gmt 1]
# return [clock format $ddi -format "\%Y\%m\%d \%H\%M\%S00"]
}

Thanks and Best Regards
Gopi

 
Is this convenient for you:
Code:
  set date [clock scan "10/20/2003 00:56:00 CST"]
  puts "local: [clock format $date]"
->local: Mon Oct 20 08:56:00 Paris, Madrid (heure d'été) 2003
  puts "GMT: [clock format $date -gmt 1]"
->GMT: Mon Oct 20 06:56:00 GMT 2003
?

I don't know how to display in an other TZ than the local TZ.

More on the clock command:
HTH

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top