LibServerResetTime

Developer Reference

Table of Contents

  1. Getting Started
  2. Functions

Getting Started

First, add LibServerResetTime (LSRT) as a dependency in your addon's manifest:

## DependsOn: LibServerResetTime

The library can be accessed via the LibServerResetTime global variable, and it is recommended that you localize it for usage; for example:

local LSRT = LibServerResetTime

Functions

Get the Unix-style timestamp of the next or previous reset:

LSRT.GetResetTimestamp( previous, weekly, server, timestamp )

previous is an optional boolean parameter. If this parameter is true, this function will return the timestamp of the previous reset (e.g., for daily resets, this will be the start of the current server date). If this parameter is false or omitted, this function will return the timestamp of the upcoming reset.

weekly is an optional boolean parameter. If this parameter is true, the returned timestamp will correspond to a weekly reset (used for Tome challenges, trial quest coffers, and weekly leaderboards). If this parameter is false or omitted, the returned timestamp will correspond to a daily reset.

server is an optional string parameter whose valid values are "NA", "EU", or "PTS", allowing the reset timestamp for a different server region to be requested. If this parameter is omitted, the current server region is assumed.

timestamp is an optional integer parameter. If a Unix-style timestamp is supplied, the reset timestamp will be calculated relative to this timestamp. If this parameter is omitted, the reset timestamp will be calculated relative to the current time.

Returns the timestamp of the next (or previous) daily (or weekly) reset, as a Unix-style (epoch) timestamp.

Get the number of seconds until the next reset:

LSRT.GetSecondsUntilNextReset( weekly, server, timestamp )

weekly is an optional boolean parameter. If this parameter is true, the returned time will correspond to a weekly reset (used for Tome challenges, trial quest coffers, and weekly leaderboards). If this parameter is false or omitted, the returned time will correspond to a daily reset.

server is an optional string parameter whose valid values are "NA", "EU", or "PTS", allowing the reset time for a different server region to be requested. If this parameter is omitted, the current server region is assumed.

timestamp is an optional integer parameter. If a Unix-style timestamp is supplied, the reset time will be calculated relative to this timestamp. If this parameter is omitted, the reset time will be calculated relative to the current time.

Returns the number of seconds until the next dail (or weekly) reset.

Get the year, month, and day of the server date:

LSRT.GetServerDate( server, timestamp )

server is an optional string parameter whose valid values are "NA", "EU", or "PTS", allowing the server date for a different server region to be requested. If this parameter is omitted, the current server region is assumed.

timestamp is an optional integer parameter. If a Unix-style timestamp is supplied, the server date will be calculated for this timestamp. If this parameter is omitted, the server date will be calculated for the current time.

Returns the integer year, month, and day representing the requested server date.

Note: The server date is aligned with the server's daily reset time and is completely agnostic to local time zones. For example, let's say you are in New York, it is currently 5 in the morning on August 21, 2024, and you are requesting the server date for the NA server. The local time is 2024-08-21 0500 EDT, and the universal time is 2024-08-21 0900 UTC. But the library will report that the server date is 2024-08-20, because the new "day", as far as dailies are concerned, does not start until an hour later at 1000 UTC.

Registers a function to be called when a daily reset happens:

LSRT.RegisterForDailyResetCallback( name, callback )

name is a unique identifier string.

callback is a function; if this parameter is omitted (nil), the registration associated with name is removed.