I'm trying to emit a datetime in snmp,
for what I understand the DateAndTime string is a string of 11 bytes representind values in this format: ( 1 letter -> 1 Byte)
y -> year
m -> month
d -> day
h -> hour
M -> minute
s -> second
u -> 1/10th of second
^ -> + or - for timezone offset
H -> timezone offset (hours)
N -> timezone offset (minutes)
yymdhMsu^HN
//Array encoding the date: 2022-11-10 12:30:15.11 UTC + 01:33
uint8_t BFF[11];
BFF[0] = 22;
BFF[1] = 20;
//-
BFF[2] = 11;
//-
BFF[3] = 10;
//,
BFF[4] = 12;
//:
BFF[5] = 30;
//:
BFF[6] = 15;
//.
BFF[7] = 11;
//,
BFF[8] = '+';
BFF[9] = 1;
//:
BFF[10] = 33;
BFF[11] = '\0';
How do I convert it to an SNMP++ OctetStr
?
It is not " 1 letter -> 1 Byte". In the EXAMPLE vs. "DISPLAY-HINT" given in defining https://www.rfc-editor.org/rfc/rfc2579.html, there are 11 bytes (could be 8) and no "letters". There is instead 1 two byte decimal field, 8 one byte decimal fields, and 1 1 byte ASCII field. The are 25 characters, but you results may vary.:
The whole RFC section for reference, along with two relevant erratum are shown below:
. (This is an INTERNET STANDARD currently, but has been around since ~1999
Note that this RFC has 2 relevant erratas: