05-31-2013 12:21 PM
Hello. I'm using LV2010. I'm writing an app that reads time and date from a device and puts it up on the computer screen. The time and date are coming from the device in a series of bytes, each representing a different aspect of time/date. They are, hours, minutes, seconds, day, month, year. Hours are in 24 hr format. I could put them together as a string, but then I want the user to be forced to keep the time/date format. That is, if I use a string, they can modify the string so it's not 2:34:23, for example. I would rather use two numeric controls. The first has its properties set to time, and the second has its properties set to date. Problem is, I'm having trouble finding a good way to convert. Converting time is pretty easy, in that I just convert all to seconds. Converting date would be a pain in the $%% if I have to figure the seconds since 1904. That seems rediculous, and there must be an easier way to do it. Any ideas? Thanks.
05-31-2013 12:37 PM
Are you trying to manipulate controls or indicators? If you are constantly getting the time from a device, why would you care about the user changing it on you?
05-31-2013 12:40 PM
I'm reading the current time from the clock in the device once when I connect. I'm wanting to put that into controls. Then, the user is free to change the current time/date and write it back to the device.
05-31-2013 12:44 PM
Look at the Date/Time to Seconds, and Seconds to Date/Time, functions. They provide a way to convert a cluster (containing values such as year, month, day of month, hours, minutes, seconds) to a timestamp, and vice versa. Sounds like you could bundle the values you read from the device into this cluster, and convert it to a timestamp.
05-31-2013 12:44 PM - edited 05-31-2013 12:45 PM
I would just use a Timestamp control.
05-31-2013 12:47 PM
Will it give correct time/date if the day of the year and the day of the week are bogus data?
05-31-2013 12:50 PM
@rickford66 wrote:
Will it give correct time/date if the day of the year and the day of the week are bogus data?
Yep. Right now I'm just passing in 0 for those and my timestamp comes out just fine.
05-31-2013 12:56 PM
Once you have the time stamp, how do you break it apart into numerical values for the time and date controls?
05-31-2013 01:01 PM
Is there something wrong with using a single Timestamp control, as crossrulz suggested?
Alternatively you could use two timestamp controls, one configured with the date unused, the other configured with the time unused, and wire your timestamp value to both of them.
I might still not be properly understanding what you want to do. You read a date and time from the device, and display it to the user. Apparently you then want the user to be able to change it. If the user does adjust it, what do you want to do with the modified value?
05-31-2013 01:03 PM
Of course, it would be that simple. I should have seen that. Yes, I have 2 time/date controls with date disabled on one and time disabled on the other. I think this is all going to work now. Thanks.