PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: dragos_sto on 05 June, 2005, 10:45:37

Title: date ....?
Post by: dragos_sto on 05 June, 2005, 10:45:37
what it the syntax fot get date from the hub
hour and minute


Title:
Post by: dragos_sto on 05 June, 2005, 11:05:50
find sollution
os.clock ()
Returns an approximation of the amount of CPU time used by the program, in seconds.
• os.date ([format [, time]])
Returns a string or a table containing date and time, formatted according to the given string
format.
If the time argument is present, this is the time to be formatted (see the os.time function for
a description of this value). Otherwise, date formats the current time.
If format starts with ‘!’, then the date is formatted in Coordinated Universal Time. After that
optional character, if format is *t, then date returns a table with the following fields: year (four
digits), month (1–12), day (1–31), hour (0–23), min (0–59), sec (0–61), wday (weekday, Sunday
is 1), yday (day of the year), and isdst (daylight saving flag, a boolean).
If format is not *t, then date returns the date as a string, formatted according with the same
rules as the C function strftime.
When called without arguments, date returns a reasonable date and time representation that depends
on the host system and on the current locale (that is, os.date() is equivalent to os.date("%c")).
• os.difftime (t2, t1)
Returns the number of seconds from time t1 to time t2. In Posix, Windows, and some other
systems, this value is exactly t2−t1.


and sorry post again in  wrong thread
Title:
Post by: plop on 05 June, 2005, 15:00:20
os.date("%x") -- returns the date.

os.clock is for the running time of the script.

plop
Title:
Post by: htb222 on 05 June, 2005, 18:48:46
os.date("%H.%M) returns the hour and minute like this: 19.37 or 07.53.
C ya
Title:
Post by: plop on 06 June, 2005, 00:12:53
QuoteOriginally posted by htb222
os.date("%H.%M) returns the hour and minute like this: 19.37 or 07.53.
C ya
this can cause weird bugs.
imagine getting the time 1miliseconds before 12:00.
you call %H - returns 11.
next you call %M - returns 00.
now you run late for 1 hour.
always use 1 call when possible.
%X - returns the date.
%x - returns the time.
check the reference manual for all the others.

plop
Title:
Post by: Madman on 06 June, 2005, 01:39:56
QuoteOriginally posted by plop
%X - returns the date.
%x - returns the time.
check the reference manual for all the others.

plop

Is init the other way around?
big X for time and small x for date?
Title:
Post by: dragos_sto on 06 June, 2005, 08:14:28
10x for answer
i found something
%H - hour
%M - minute
%T time (hour:minute:seconds)
%d - day
%m - month (arabic)
%h - month (letter)
%Y - year

and other but i dont know them :D
Title:
Post by: plop on 06 June, 2005, 23:27:49
%a abbreviated weekday name (e.g., Wed)
%A full weekday name (e.g., Wednesday)
%b abbreviated month name (e.g., Sep)
%B full month name (e.g., September)
%c date and time (e.g., 09/16/98 23:48:10)
%d day of the month (16) [01-31]
%H hour, using a 24-hour clock (23) [00-23]
%I hour, using a 12-hour clock (11) [01-12]
%M minute (48) [00-59]
%m month (09) [01-12]
%p either "am" or "pm" (pm)
%S second (10) [00-61]
%w weekday (3) [0-6 = Sunday-Saturday]
%x date (e.g., 09/16/98)
%X time (e.g., 23:48:10)
%Y full year (1998)
%y two-digit year (98) [00-99]
%% the character `%?
or click here (http://www.lua.org/pil/22.1.html)

@madman: your right, i mixed them up.

plop