Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
time format in 5.0
#1
Dean, I am troubleshooting a driver that used to work in the past, but now with the daylight change noticed an event to not work correctly.

I traced back to the following in a CML driver:

Code:
          m_Time.SetDefFmt("%(Y,4,0),%(M,2,0),%(D,2,0),%(H,2,0),%(u,2,0)");
          Stamp := m_Time.GetCurStamp();
           MsgText := "CFGTIME";
          MsgText.AppendFmt(Stamp);
This creates MsgText to be CFGTIME14895007530420000
instead of CFGTIMEyyyy,mm,dd,hh,mm
I am almost certain that this code worked in the past, not sure what changed, what I missed that the format is ignored.
Thanks, Lleo
Reply
#2
I don't think that could have ever worked the way you were expecting. The default format only works on the time object. When you do GetCurStamp() you are getting the Card8 raw time stamp value out, so appending it to MsgText would get you the results you see. No formatting set on the time object would follow that Card8 value around.

For what you want to do, you would need to append the time object itself, which would cause it to be formatted out using the time format you have set on it.
Dean Roddey
Explorans limites defectum
Reply
#3
Thanks Dean, it makes sense, not sure how I missed it, since it compiled OK, I may have never noticed that this part was not working as intended.

For anyone stumbling on this thread:

Code:
          Stamp.SetFromStamp(m_Time.GetCurStamp());
          Stamp.SetDefFmt("%(Y,4,0),%(M,2,0),%(D,2,0),%(H,2,0),%(u,2,0)");
           MsgText := "CFGTIME";
          MsgText.AppendFmt(Stamp);

The above produces the string "CFGTIMEyyy,mm,dd,hh,mm" as expected.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Triggered Event only works every second time znelbok 2 99 10-27-2020, 12:05 PM
Last Post: znelbok
  Handling Daylight Savings Time kblagron 10 1,179 03-17-2020, 07:35 AM
Last Post: Dean Roddey
  Timers Driver / Field Time Image / Seconds gReatAutomation 1 420 03-16-2020, 05:48 PM
Last Post: Dean Roddey
  LogicServer Elapsed Time and Triggered Event gReatAutomation 6 1,026 08-17-2019, 07:53 AM
Last Post: gReatAutomation
  Time formatting RunTime Time Variable? gReatAutomation 5 1,100 08-14-2019, 05:23 AM
Last Post: gReatAutomation
  Use UI to alter scheduled event time IVB 1 566 07-09-2019, 08:42 PM
Last Post: IVB
  Getting a Card8 into a Time Format in CML kblagron 2 836 03-14-2019, 11:15 PM
Last Post: kblagron
  What would the proper trigger to be for a time or a X min before sundown? ghurty 1 969 01-10-2019, 10:08 AM
Last Post: Dean Roddey
  GetCurMillis immune to system time change? rbroders 6 1,574 12-09-2018, 02:58 PM
Last Post: rbroders
  Down time today Dean Roddey 0 811 11-19-2018, 05:07 PM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)