Author Topic: BasicLabel Time Display Leading Zero for 0-9 Value  (Read 1586 times)

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
BasicLabel Time Display Leading Zero for 0-9 Value
« on: October 16, 2020, 02:03:09 PM »
I have some BasicLabels displaying the month/date/year  hour:minute (and some with :second). I want to show the day/time in the PLC to match logs in it, not use the computer day/time that may be off. Also, I can click on each label and enter a correct time to write to the PLC.

I don't like the display when the time is say 1: 3: 5, I want it to show 1:03:05. What I am doing now is setting 3 bits in the PLC if the hour, minute or second are 0-9 and using them as visibility bits for 6 labels.

I have 2 for hour - one showing the 2 digit value if the bit is NOT, and one showing the one digit value with a '0' prefix if the bit is on. Sort of a clunky way of doing it.

Is there a property for BasicLabel that if it is a single digit, or less than a specified value, a prefix is added?

If it was a specified value then adding a prefix or suffux may be usable for applications other than time - temperature, pressure, level, flow, pH, etc.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: BasicLabel Time Display Leading Zero for 0-9 Value
« Reply #1 on: October 16, 2020, 03:28:57 PM »
BasicLabels have DisplayAsTime property, where your PLC can supply total number of seconds, or NumericFormat property where you can put "00" and it will show 9 as 09.

You might possibly benefit from this, as a general knowledge, which you can see being used as TimestampFormat in the BasicDataLogger components:

   https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: BasicLabel Time Display Leading Zero for 0-9 Value
« Reply #2 on: October 16, 2020, 04:11:13 PM »
Thanks Godra.

Never saw that down on the properties. Guess I'm going to have to find time to start trying every setting for all the objects sometime.