[go: up one dir, main page]

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

BUG: 'parsing time "2024-05-01T15:36:59" as "2006-01-02T15:04:05Z07:00": cannot parse "" as "Z07:00"' #47

Open
surdaft opened this issue May 2, 2024 · 0 comments · May be fixed by #48

Comments

@surdaft
Copy link
surdaft commented May 2, 2024

I am trying to use the alarmserver with an Annke NVR which returns an event struct like this:

Content-Type: application/xml; charset="UTF-8"
Content-Length: 461

<EventNotificationAlert version="1.0" xmlns="http://www.std-cgi.com/ver20/XMLSchema">
<ipAddress>xxx.xxx.x.xxx</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>xx:xx:xx:xx:xx:xx</macAddress>
<channelID>0</channelID>
<dateTime>2024-05-02T09:43:06</dateTime>
<activePostCount>0</activePostCount>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>

The issue is when the alarmserver comes to unmarshal the XML it fails at the timestamp due to the missing timezone tag - hence the cannot parse "" as "Z07:00"

Reading this article it looks as though we can just create our own Time struct which can handle the format we want to parse. Allowing for a config option to override the default. Eg;

hikvision:
  enabled: true
  cams:
    xx:
      address: xx.xx.xx.xx
      username: xxx
      password: xxx
      event-time-format: 2006-01-02T15:04:05
surdaft added a commit to surdaft/alarmserver that referenced this issue May 3, 2024
@surdaft surdaft linked a pull request May 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant