Alternate Time?

Greetings XOJO people:

I am working on a program which is likely to be deployed in remote (really remote) field locations, far from common communications infrastructure. Think, particularly, of tropical rain forests (Amazon, Congo, SE Asia, for examples). We can assume that the hardware had accurate time before leaving infrastructure coverage, though this time COULD be for a very different time zone.

I would like the app to be able to maintain a local time referenced to the hardware’s time setting without having to change the the hardware’s good time. I see that there is a property DateTime.SecondsFrom1970. I think that I can get a difference between that and local time.

The question then is: Can I create a second DateTime object that has the necessary offset without interfering with other uses of date or time by this application? For example, suppose that I create a datetime object and set its DateTime.SecondsFrom1970 to be 2 hours different from what the hardware says is it’s time. Will this new datetime object be updated in real time from the hardware’s clock while not effecting the datetime as reported by other datetime objects within the app?

Many thanks
Jim Wagner
Oregon Research Electronics

No. It will be static.

Thanks Tim,

Then I have to create a new “localdatetime” object each time it is used, I guess. Or update the TotalSeconds (or its surrogate) each time.

Jim

I don’t understand the problem and I’m getting confused about the seconds.

Like 7:59 PM Central and I can create a datetime to 5:59 PM Pacific by adjusting the time zone. Or do you actually want to change the SecondsFrom1970 from what the computer reports?

I want to set a local time FOR THE APP, but keep it referenced to the computers real time clock without changing the real time clock.

I now see that what I need to do is have the user enter the local time and determine the difference (in seconds) between that time and the computer’s time. Then, whenever a new local time is needed, I use the seconds offset found earlier with the DateTime’s clock that is still based on computer time.

Jim

My recommendation, use the TimeZone object.

This object will give you control of the exact time of the equipment that uses your application.

The server will always have the “standard” time you can use this information as a reference. So, the client could use different hours.

Using the TimeZone object helps you to standardize the time. So you can use one regardless of where you are in the world.

Example:


Var Get_Date As DateTime = DateTime.Now(New TimeZone("America/Mexico_City"))
1 Like

I have seen too many times where the computer is misconfigured, without using time zone. But I will check that.

Thanks
Jim

Ah, you want to ask the year/month/day/hour/min/second and TimeZone so you can create a correct DateTime, compare that with the computer time, and then, when you need a new date, just use the calculated difference to create a new date.

I think this can work if the operator can’t change the computer clock.

If I understand the problem, the computer isn’t connected to the internet and therefore cannot automatically adjust its clock. If you take your laptop from New York to London, it will automatically adjust to the local timezone. But if you take that laptop from New York to the middle of the Amazon rain forest, it will still be on New York time, because it can’t auto adjust.

It sounds like you need to have the user select the actual time zone and then adjust all times to that zone via the TimeZone object. I don’t think you’ll have to use seconds all the time. But that would work, too.

Thanks, Tim -

I think that you have the situation. I was hoping to avoid requiring that the user change the computer’s clock, but what you suggest would certainly work, and do it cleanly. I’ll rethink this problem a bit and try to clarify, in my own mind, what is really needed. Many of the places this will go will have “research stations” that have internet via satellite. But, not all. The real question will be how much work I should put into it for a few users. On the other hand, that is the sort of picky little thing that gets gossiped around and can negatively effect sales.

Appreciate your suggestion -

Jim

if the computer/device has gps it’s will mostlikely be used as a time sampler (time will be updated from there) you can verify that maybe by trying to turn off the internet and run the app a while and sample the DateTime.Now (secondsFrom1970 is always GMT-0, really close to UTC)

That would be nice but most laptops do not have GPS.

Jim

Could you perhaps display a timezone chooser in your app and let the app use this information?
Then you’d not need to change the OS timezone.

That is a useful idea! Thank you!

Jim

You’re welcome :slightly_smiling_face: