nsmcp::LogRecordParser method timestampSeconds (public)

 <instance of nsmcp::LogRecordParser[i]> timestampSeconds timestamp

Defined in /usr/local/ns/tcl/nsmcp/log-record.tcl

Convert a supported NaviServer log timestamp to epoch seconds. Validate the timestamp layout and retain supported fractional-second information.

Parameters:
timestamp (required)
Parsed timestamp or timing base supplied by the parser.
Returns:
The parsed epoch timestamp, or an empty result for an invalid timestamp.

Testcases:
No testcase defined.
Source code:
if {![regexp {^([0-9]{2}/[A-Za-z]{3}/[0-9]{4}:[0-9]{2}:[0-9]{2}:[0-9]{2})(\.[0-9]+)?( [+-][0-9]{4})?$} $timestamp -> base fraction zone]} {
    return {}
}
set format {%d/%b/%Y:%H:%M:%S}
if {$zone ne ""} {
    append base $zone
    append format { %z}
}
if {[catch {
    clock scan $base -format $format -locale C
} seconds]} {
    return {}
}
if {$fraction ne ""} {
    set seconds [expr {$seconds+double("0$fraction")}]
}
return $seconds
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: