This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Force 2 digit
#7
Hi,

you can try as Domotiqa recommended. Possible variant - show your data with zeroes, when you need enter data - zero is not so important may be.

Long time ago I did something you need with hour and minutes less 10, I wanted zero in front:

Code:
time = {
day = wday,
hour = now.hour,
minute = now.min,
second = now.sec,
}
h1 = now.hour
m1 = now.min
ms = now.month
weekday1 = wday
if now.hour == 0 then h1 = "00"
end
if now.hour == 1 then h1 = "01"
end
if now.hour == 2 then h1 = "02"
end
if now.hour == 3 then h1 = "03"
end
if now.hour == 4 then h1 = "04"
end
if now.hour == 5 then h1 = "05"
end
if now.hour == 6 then h1 = "06"
end
if now.hour == 7 then h1 = "07"
end
if now.hour == 8 then h1 = "08"
end
if now.hour == 9 then h1 = "09"
end

if now.min == 0 then m1 = "00"
end
if now.min == 1 then m1 = "01"
end
if now.min == 2 then m1 = "02"
end
if now.min == 3 then m1 = "03"
end
if now.min == 4 then m1 = "04"
end
if now.min == 5 then m1 = "05"
end
if now.min == 6 then m1 = "06"
end
if now.min == 7 then m1 = "07"
end
if now.min == 8 then m1 = "08"
end
if now.min == 9 then m1 = "09"
end
if now.hour == 0 then h1 = "00"
end

if weekday1 == 1 then weekdayru = "Понедельник"
end
if weekday1 == 2 then weekdayru = "Вторник"
end
if weekday1 == 3 then weekdayru = "Среда"
end
if weekday1 == 4 then weekdayru = "Четверг"
end
if weekday1 == 5 then weekdayru = "Пятница"
end
if weekday1 == 6 then weekdayru = "Суббота"
end
if weekday1 == 7 then weekdayru = "Воскресенье"
end

Simple but works. In result I see time with zeroes in front and weekdays text in required language. This is just like an idea. And of course you need take in mind data types and convert it if needed..

BR,

Alex
Reply


Messages In This Thread
Force 2 digit - by jmir - 03.11.2023, 07:12
RE: Force 2 digit - by Daniel - 03.11.2023, 08:33
RE: Force 2 digit - by jmir - 06.11.2023, 10:58
RE: Force 2 digit - by Daniel - 06.11.2023, 11:29
RE: Force 2 digit - by jmir - 07.11.2023, 09:45
RE: Force 2 digit - by domotiqa - 11.01.2024, 15:16
RE: Force 2 digit - by AlexLV - 11.01.2024, 21:50
RE: Force 2 digit - by admin - 12.01.2024, 08:51

Forum Jump: