Jump to content

سؤال في التايم time


Recommended Posts

 

setTimer( function()	
	local Realtime = getRealTime()
	local hour = Realtime.hour
	local Min = Realtime.minute
	local sec = Realtime.second
		if hour == 12 then
			outputChatBox( "Test", root )
		end
end, 1000, 0 )

 

الحين الكود ذا صح

ولو صح كيف اسويه

كيف اخليها

AM

او 

PM

Link to comment

AM اذا كانت الساعة أكبر من أو تساوي 0 وأصغر من 12 خليها

PM واذا كانت الساعة أكبر من أو تساوي 12 وأصغر من 24 خليها

Link to comment
35 minutes ago, N3xT said:

AM اذا كانت الساعة أكبر من أو تساوي 0 وأصغر من 12 خليها

PM واذا كانت الساعة أكبر من أو تساوي 12 وأصغر من 24 خليها

if hour >= 0 and hour < 12 then status = "AM"

elseif hour >= 12 and hour < 24 then status = "PM"

 

  • Like 1
Link to comment
-->> داخل اللوب تستخدم الدالة اللي تحت
-->> ترجع لك القيم التالية
-->> hour, minute, timeState : الساعة , الدقيقة , حالة الوقت(صباحاً,مساءًا)وهكذا

function getTimes()
	local hour,minute=getTime();
	local timeState=false;
	if hour >= 12 then
		timeState="PM";
	end
	if hour < 12 then
		timeState="AM";
	end
	if minute < 10 then
		minute="0"..tostring(minute);
	end
	if hour > 12 then
		hour=hour-12
	end
	if timeState then
		if tostring(hour):len() == 1 then
			hour="0"..tostring(hour);
		end
	end
	local hour,minute= tostring(hour),tostring(minute);
	return hour,minute,timeState
end

-->> TEST : تجربة
hour,min,timeState=getTimes();
print(hour..":"..min.." "..timeState)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...