GetTimeProperty: Difference between revisions

From Zandronum Wiki
(Remove Devfeature)
(Correct <tt>TM_DAY</tt> range)
Tag: Source edit
 
(3 intermediate revisions by 2 users not shown)
Line 6: Line 6:
=== Parameters ===
=== Parameters ===
* ''timestamp'': The timestamp to localize.
* ''timestamp'': The timestamp to localize.
* ''which'': Which attribute to return.
* ''which'': Which attribute to return; see the [[#Time properties]] table below.
* ''utc'': If true, the timestamp will be localized using the UTC timezone, local timezone otherwise
* ''utc'': If true, the timestamp will be localized using the UTC timezone, local timezone otherwise.


== Time properties ==
=== Time properties ===
{|
{| class="wikitable"
!Property
!Property
!Range
!Range
Line 28: Line 28:
|-
|-
|<tt>TM_DAY</tt> (3)
|<tt>TM_DAY</tt> (3)
| [0, 30]
| [1, 31]
| Days
| Days
|-
|-
Line 44: Line 44:
|}
|}


== Result value ==
=== Return value ===
Localizes the given timestamp and returns an attribute of it.
Localizes the given timestamp and returns an attribute of it.


Note that due to ACS's limitations, the timestamp is suspectible to the [http://en.wikipedia.org/wiki/Year_2038_problem year 2038 problem].
Note that due to ACS's limitations, the timestamp is suspectible to the [[wikipedia:Year 2038 problem|year 2038 problem]].


== See Also ==
== Examples ==
*[[SystemTime]]
The following script checks if the game is being played on a Thursday the 20th.
*[[Strftime]]
<syntaxhighlight lang="c" line="1">
script 1 OPEN
{
    if (GetTimeProperty(SystemTime(), TM_WEEKDAY) == 4 && GetTimeProperty(SystemTime(), TM_DAY) == 20)
        PrintBold(s:"Happy Thursday the 20th!");
}
</syntaxhighlight>
 
== See also ==
* [[SystemTime]]
* [[Strftime]]
 
[[Category:ACS functions]]

Latest revision as of 19:10, 22 May 2023

This article documents a Zandronum-specific ACS feature which may not be supported by ZDoom and its other child ports.

int GetTimeProperty (int timestamp, int which[, int utc])

Usage

Parameters

  • timestamp: The timestamp to localize.
  • which: Which attribute to return; see the #Time properties table below.
  • utc: If true, the timestamp will be localized using the UTC timezone, local timezone otherwise.

Time properties

Property Range Description
TM_SECOND (0) [0 - 61] Seconds.
Result is generally within [0, 59] but may very rarely exceed due to leap seconds.
TM_MINUTE (1) [0 - 59] Minutes
TM_HOUR (2) [0, 23] Hours
TM_DAY (3) [1, 31] Days
TM_MONTH (4) [0, 11] Month of the year
TM_YEAR (5) [1901, 2038] Year
TM_WEEKDAY (6) [0, 6] Weekday (Sunday is 0)

Return value

Localizes the given timestamp and returns an attribute of it.

Note that due to ACS's limitations, the timestamp is suspectible to the year 2038 problem.

Examples

The following script checks if the game is being played on a Thursday the 20th.

script 1 OPEN
{
    if (GetTimeProperty(SystemTime(), TM_WEEKDAY) == 4 && GetTimeProperty(SystemTime(), TM_DAY) == 20)
        PrintBold(s:"Happy Thursday the 20th!");
}

See also