Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for RFC 2579 DateAndTime conversion #321

Closed
SuperQ opened this issue Aug 14, 2018 · 7 comments
Closed

Support for RFC 2579 DateAndTime conversion #321

SuperQ opened this issue Aug 14, 2018 · 7 comments

Comments

@SuperQ
Copy link
Member

SuperQ commented Aug 14, 2018

It would be useful to convert RFC 2579 DateAndTime to a unix timestamp.

From SNMPv2-TC:

DateAndTime ::= TEXTUAL-CONVENTION
    DISPLAY-HINT "2d-1d-1d,1d:1d:1d.1d,1a1d:1d"
    STATUS       current
    DESCRIPTION
            "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..13
             10      11    minutes from UTC          0..59

            * Notes:
            - the value of year is in network-byte order
            - daylight saving time in New Zealand is +13

            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."
    SYNTAX       OCTET STRING (SIZE (8 | 11))
@brian-brazil
Copy link
Contributor

Note that if there's no timezone, we can't properly convert.

@RichiH
Copy link
Member

RichiH commented Aug 14, 2018

That's true, but arguably a configuration error by the end user. If they put wrong or incomplete data in other config, we can not do anything but expose it as such.

@brian-brazil
Copy link
Contributor

It's not a configuration error of the user if the device is incapable of outputting timezones.

@RichiH
Copy link
Member

RichiH commented Aug 14, 2018

While that is true, the common case, in my experience with network devices, is that TZ info is optional, but always supported.

@SuperQ
Copy link
Member Author

SuperQ commented Aug 14, 2018

The spec says we can basically fake it if the zone is not returned by the device. We can apply something like time.Now().Zone(). Documenting that "Time zones are not always supported" is probably good enough.

@brian-brazil
Copy link
Contributor

We'd have to presume UTC.

@SuperQ
Copy link
Member Author

SuperQ commented Aug 14, 2018

Yes, you're right, UTC is better. I am doing some testing on my NAS server which returns no zone information, but happens to be set to UTC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants