Skip to content
Tcl Source Code View Ticket
Login

View Ticket

clock scan doesn't handle GMT+xxxx timezones

Closed / Fixed217968ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:46:55
OriginalBugID: 4862 RFE
Version: 8.3
SubmitDate: '2000-04-05'
LastModified: '2000-06-26'
Severity: MED
Status: Closed
Submitter: techsupp
ChangedBy: ericm
RelatedBugIDs: 5297
OS: Windows NT
OSVersion: 4.0 sp5
Machine: AMD K6-2/333 128MB RAM
FixedDate: '2000-06-26'
ClosedDate: '2000-10-25'


Name:
David Cuthbert

CVS:
05 April 2000 00:30 EDT

Extensions:
[incr Tcl] 3.1.0

CustomShell:
None

Comments:
The following Tcl script is being used as a workaround:

  proc ::Kanga::Article::ScanDate {date} {
     # Try to handle this in Tcl, if possible
      set cr [catch { set scan [clock scan $date] }]

      if {!$cr} { return $scan }

      # Hmm... ok, try to pick out any strings like "GMT+0100" or "+0100"
      set pluspos  [string last "+" $date]
      set minuspos [string last "-" $date]

      if {$pluspos > $minuspos} { 
  set pos $pluspos
      } else {
  set pos $minuspos 
      }

      if {$pos != -1} {
  # Ok, see if there are four digits following this
  set offset [string range $date [expr {$pos+1}] [expr {$pos+4}]]
  if {[string length $offset] == 4 &&
      [string is digit $offset] &&
      [string index $offset end] == "0"} {
      # Finally, see if there is "GMT" or "GMT " preceding this
      if {[string range $date [expr {$pos-3}]  [expr {$pos-1}]] == "GMT"} {
  set basedate [string range $date 0 [expr {$pos-4}]]
      } elseif {[string range $date [expr {$pos-4}]  [expr {$pos-1}]] == "GMT "} {
  set basedate [string range $date 0 [expr {$pos-5}]]
      } else {
  set basedate [string range $date 0 [expr {$pos-1}]]
      }

      set cr [catch {
  if {[string index $date $pos] == "-"} {
      set mult -1
  } else {
      set mult 1
   }

  set hr [string range $offset 0 1]
  set mn [string range $offset 2 3]

   # Avoid accidental octal conversion
    if {[string index $hr 0] == "0"} { 
        set hr [string index $hr end]
    }

    if {[string index $mn 0] == "0"} {
        set mn [string index $mn end]
    }

    set scan [expr {[clock scan $basedate -gmt 1] +
    $mult * $hr * 3600 +
    $mult * $mn * 60}]
        }]

      if {!$cr} {
  return $scan
      }
  }
      }

      # Nothing has worked.  Return an error
      error "cannot convert $date to a date/time."
  }

DesiredBehavior:
I would like [clock scan] to be able to handle: "Wed, 15 Mar 2000 16:50:23 +0100" (produced by some newsreaders)

Workaround:
welch Closed ticket [217968ffff]. [History diff]2000-10-26 08:10:57
dgp Ticket [217968ffff]: 3 changes [History diff]2001-04-05 06:56:34
Log in (anonymous is fine) to add a comment.