Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting number of seconds to Hours:Minutes:Seconds
#31
I just added one. So you give it a number of seconds and it gives back hours, mins, and secs into three variables. So that'll be in the next drop.
Dean Roddey
Explorans limites defectum
Reply
#32
Thanks Dean, I look forward to trying it out!
Reply
#33
At the risk of sounding like someone who is never satisfied, how about expanding it handle a value greater than 24 hours by including the number of days in the output. If you do, I promise I won't ask for the number of months if days > 30, etc. (although someone else might). :-D

Ira
Reply
#34
There aren't enough action parameters for that, so I get to claim inability on that one.
Dean Roddey
Explorans limites defectum
Reply
#35
Dean Roddey Wrote:There aren't enough action parameters for that, so I get to claim inability on that one.

Since I haven't installed CQC yet, I have absolutely no idea what you mean, so you get off easy this time. ;-)

My Fit-PC2 came in today, so as soon as I get a PS/2 to USB adapter for the old keyboard I have laying around, I will start configuring it. CQC installation is just around the corner.

Regards,
Ira
Reply
#36
So I just gave this a try, but ran into a little problem. I'm running 3.0.9.
Code:
//
LocalVars::SetVariable
    P1=LVar:int_elkM1_Counter01
    P2=$(elkM1.CustVal20)

LocalVars::Subtract
    P1=LVar:int_elkM1_Counter01
    P2=$(elkM1.Counter01)

System::CvtToElapsed
    P1=LVar:int_elkM1_Counter01
    P2=LVar:int_elkM1_Counter_Hours
    P3=LVar:int_elkM1_Counter_Minutes
    P4=LVar:int_elkM1_Counter_Seconds

System::LogMsg
    P1=elkM1
    P2=0
    P3=medication timer status: %(LVar:int_elkM1_Counter_Hours)  %(LVar:int_elkM1_Counter_Minutes)  %(LVar:int_elkM1_Counter_Seconds)
    P4=Status

But when I select the save button, an error popped up saying:
Parameters 1 of a 'CvtToElapsed' command is invalid. Reason='Expected an unsigned value'.

Any input would be appreciated, thanks!
Reply
#37
It wants the actual value, not the name the variable, so dereference the variable, i.e. %(LVar:int_elkM1_Counter01). I think that's the problem.
Dean Roddey
Explorans limites defectum
Reply
#38
Dean Roddey Wrote:OK, the problem is that, as mentioned before, if you set the value of a time field from a text value, as is happened in my example above, then it assumes it is a hex value, since times are always formatted out as hex. So 14000 is being taken as hex. If you pass in 0x36B0 as the initial value, which is 14000 in hex, then it works correctly.

If you are passing in the value of a time based field, then it should work correctly, since it'll get formatted out as text when it's set on the variable. It's just when it's being set like I did from a text string.

So anyway, here is what I ended up with. I think this is correct.

Code:
// The original count of seconds into a Time variable
LocalVars::CreateVariable
    P1=LVar:Time
    P2=Time
    P3=
    P4=0x36B0

// Convert to the standard 100ns time stamp form
LocalVars::Multiply
    P1=LVar:Time
    P2=10000000

// Pull out the separate time bits
System::GetTimeParts
    P1=%(LVar:Time)
    P2=LVar:Hours
    P3=LVar:Mins
    P4=LVar:Secs

// Format them out to a text widget
Output::SetText
    P1=%(LVar:Hours)h, %(LVar:Mins)m, %(LVar:Secs)s


That results in

3h, 53m, 20s

I'm trying to reproduce your example and I getting only "000" into the output widget. I even tried to change the types of the LVar:Mins and LVar:Hours since the code didn't included it.

What I'm really trying to do is get the system time/date (not the 0x36B0) and stuff the parts into a string that will have the following format hhmmDDMMYY (hh - hour, mm - minutes, DD - day of the month, MM -month and YY is the year)
Reply
#39
Use the System::FormatTimeVal() command. Pass it a time stamp and you can use the standard formatting pattern values.
Dean Roddey
Explorans limites defectum
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Week Number RTV znelbok 1 111 10-22-2019, 06:58 PM
Last Post: Dean Roddey
  Generate Random Number in a Trigger batwater 1 947 12-10-2017, 12:43 PM
Last Post: Dean Roddey
  I have an event that I want to happen 5 hours after sunset. ghurty 8 3,778 03-24-2017, 08:40 AM
Last Post: Dean Roddey
  Converting Int4 to String zra 11 2,749 04-03-2015, 02:19 PM
Last Post: zra
  Correspond image to number? jkmonroe 1 1,302 02-07-2015, 08:10 PM
Last Post: Dean Roddey
  vBulletin getting excess number of access violations Mark Stega 3 1,737 06-20-2014, 08:49 AM
Last Post: Dean Roddey
  Displaying slot number diy8888 18 4,024 05-19-2014, 05:22 AM
Last Post: Dean Roddey
  Not a Valid Zone Number for Blaster Jnetto 21 4,636 12-24-2013, 03:51 PM
Last Post: Dean Roddey
  Every 10 seconds exactly I get ???? on every field in my IV Deephaven 13 2,238 07-16-2013, 01:24 PM
Last Post: Deephaven
  Conver text to number? jpants 3 1,284 03-16-2010, 10:47 AM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)