Author Topic: Clarification of os.date()  (Read 3580 times)

0 Members and 1 Guest are viewing this topic.

Herodes

  • Guest
Clarification of os.date()
« on: 24 September, 2006, 15:20:24 »
Many of you scripters out there are using the os.date function from the os lib of Lua in PtokaX...
There goes the manual explanation...

Quote from: The 5.1 Lua Manual
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 this optional character, if format is the string "*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 to 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")).

Notice the vague part!

"If format is not "*t", then date returns the date as a string, formatted according to the same rules as the C function strftime."

I was really confused at this part myself when trying to get to know the os.date function,... I was looking for what this func can take,...
and I found it :) there you go the complete proper string formations of os.date():

"%a"The abbreviated weekday name. Example: Thu.
"%A"The full weekday name. Example: Thursday.
"%b"The abbreviated month name. Example: Sep.
"%B"The full month name. Example: September.
"%dThe two-digit day of the month padded with leading zeroes if applicable. Example: 09.
"%e"The day of the month space padded if applicable. Example: 9.
"%H"The two-digit military time hour padded with a zero if applicable. Example: 16.
"%I"The two-digit hour on a 12-hour clock padded with a zero if applicable. Example: 04.
"%j"The three-digit day of the year padded with leading zeroes if applicable. Example: 040.
"%k"The two-digit military time hour padded with a space if applicable. Example: 9.
"%l"The hour on a 12-hour clock padded with a space if applicable. Example: 4.
"%m"The two-digit month padded with a leading zero if applicable. Example: 09.
"%M"The two-digits minute padded with a leading zero if applicable. Example: 02.
"%p"Either AM or PM. Language dependent.
"%S"The two-digit second padded with a zero if applicable. Example: 04.
"%w"The numeric day of the week ranging from 0 to 6 where 0 is Sunday. Example: 0.
"%x"The language-aware standard date representation. For most languages, this is just the same as %B %d, %Y. Example: September 06, 2002.
"%X"The language-aware time representation. For most languages, this is just the same as %I:%M %p. Example: 04:31 PM.
"%y"The two-digit year padded with a leading zero if applicable. Example: 01.
"%Y"The four-digit year. Example: 2001.

Now you are a C programmer too!! :)
« Last Edit: 24 September, 2006, 15:22:50 by Herodes »

PtokaX forum

Clarification of os.date()
« on: 24 September, 2006, 15:20:24 »

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 730
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Clarification of os.date()
« Reply #1 on: 24 September, 2006, 23:49:25 »
Could you please run a wikify() on this? :)
Everything could have been anything else and it would have just as much meaning.

Herodes

  • Guest
Re: Clarification of os.date()
« Reply #2 on: 25 September, 2006, 00:05:24 »
done ;) View it here

PtokaX forum

Re: Clarification of os.date()
« Reply #2 on: 25 September, 2006, 00:05:24 »