LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert separate hours, minutes and seconds to time?

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.

 

0 Kudos
Message 1 of 10
(4,448 Views)

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?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 10
(4,439 Views)

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.

0 Kudos
Message 3 of 10
(4,437 Views)

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.

0 Kudos
Message 4 of 10
(4,433 Views)

I would just use a Timestamp control.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 10
(4,430 Views)

Will it give correct time/date if the day of the year and the day of the week are bogus data?

0 Kudos
Message 6 of 10
(4,428 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 10
(4,422 Views)

Once you have the time stamp, how do you break it apart into numerical values for the time and date controls?

0 Kudos
Message 8 of 10
(4,417 Views)

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?

0 Kudos
Message 9 of 10
(4,413 Views)

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.

 

0 Kudos
Message 10 of 10
(4,407 Views)