Author Topic: Timestamps  (Read 383 times)

GarnetT

  • Newbie
  • *
  • Posts: 7
    • View Profile
Timestamps
« on: May 15, 2017, 08:44:01 pm »
Is anyone having much luck with the time functions? Specifically I want to return the current hour from modul . Secondly, when I read this value, the format (converted to string) appears as such:
2017-05-16T00:59:59+00:00

My PC clock is reading that same date, but the time is 7:42 pm. Hours, minutes, and seconds seem to be a bit off.
None the less, I still want to fetch the hours integer value.

Garnet

Social Buttons


Nick_W

  • Full Member
  • ***
  • Posts: 212
    • View Profile
Re: Timestamps
« Reply #1 on: May 20, 2017, 01:36:32 pm »
Checkout my Time library, everything i know about timestamps is in it.

BTW the module time is really the gateway time (obtained from NTP server), and sent to the module when it connects. Timezone doesn't really seem to work though...

GarnetT

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Timestamps
« Reply #2 on: May 21, 2017, 09:34:14 am »
Thanks Nick,
I've just google'd you and am checking it out now.
Garnet

bdevlin

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Timestamps
« Reply #3 on: July 09, 2017, 01:08:19 pm »
I can't seem to get datetime.now() until the second request from a module. It kinda makes sense I guess, but that means the modules first response is bad data.
« Last Edit: July 11, 2017, 06:08:42 pm by bdevlin »

mc-John

  • Global Moderator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Re: Timestamps
« Reply #4 on: July 10, 2017, 11:17:11 am »
The code to get date/time info looks like this:

Code: [Select]
        Dim dat As DateTime = DateTime.Now
        Dim hr As Integer = dat.Hour
        Dim sec As Integer = dat.Second
        Dim month As Integer = dat.Month

bdevlin

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Timestamps
« Reply #5 on: July 12, 2017, 02:53:17 pm »
I can get data from DateTime.Now() but The data transmitted via publish in the first module boot is "2000-01-01T00:00:00+00:00", then the second and subsequent publish the time nearly correctly, however it's off by an hour (-8:00N is my time zone). I can't figure out how to force the module to fetch the time fist in the boot() event successfully first.

This seems to work ok, any problems with this method?

    Shared Event Boot()
        While DateTime.Now().Year= 2000
        End While
    End Event

mc-John

  • Global Moderator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Re: Timestamps
« Reply #6 on: July 17, 2017, 09:21:06 am »
That will work. To limit power consumption you could sleep for 100mSec in the while loop.

bdevlin

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Timestamps
« Reply #7 on: July 17, 2017, 01:35:04 pm »
So that would be this in uSeconds?

        While DateTime.Now().Year= 2000
            Thread.Sleep(100000)   
        End While

mc-John

  • Global Moderator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Re: Timestamps
« Reply #8 on: July 18, 2017, 09:56:46 am »
That's correct