Tuesday, August 17, 2010

CTS System - SNMP Decode dateandTime

We have a value in our MIB for notifying when an specific call started:

Object ctpcStartDateAndTime

"This object specifies the value of local date and time when a call is started.
 
http://tools.cisco.com/Support/SNMP/do/BrowseOID.do?local=en&translate=Translate&typeName=DateAndTime

This Object has variable type as "DateAndTime". DateAndTime is a standard Textual Convention which is defined in the SNMPv2-TC. DateAndTime is resolved to base data type OCTET STRING. The DISPLAY-HINT format for DataAndTime is given as follows.

DISPLAY-HINT "2d-1d-1d,1d:1d:1d.1d,1a1d:1d"

The date-time specification is as follows.


"A date-time specification.

field octets contents range
----- ------ -------- -----
1 1-2 year 0..65536
2 3 month 1..12
3 4 day 1..31
4 5 hour 0..23
5 6 minutes 0..59
6 7 seconds 0..60
(use 60 for leap-second)
7 8 deci-seconds 0..9
8 9 direction from UTC '+' / '-'
9 10 hours from UTC 0..11
10 11 minutes from UTC 0..59

For example, Tuesday May 26, 1992 at 1:30:15 PM EDT would be
displayed as:

1992-5-26,13:30:15.0,-4:0

Note that if only local time is known, then timezone information (fields 8-10) is not present."


Valid Usage

SnmpVar snmpvar = syntax.CreateVariable("'07:D2:09:03:0C:14:20:03:2B:07:00'");//hex format, length 11 bytes
SnmpVar snmpvar = syntax.CreateVariable("'07:D2:09:03:0C:14:20:03'");//hex format, length 8 bytes
SnmpVar snmpvar = syntax.CreateVariable("2002-9-21,13:53:32.3,-7:0");//string format, length 11 bytes
SnmpVar snmpvar = syntax.CreateVariable("2002-9-21,13:53:32.3");//string format, length 8 byte

Example:

07 DA 08 09 0E 13 31 00 
 
07DA = 2010
08   = August
09   = 9th
0E   = 14
13   = 13 minutes
31   = 31 seconds
00   = deciseconds


The value of year is in network-byte order.

No comments:

Post a Comment