Module LibClockTST
Project: LibClockTST
Author: Arne Rantzen (Tyx) Created: 2020–01–20 Updated: 2020–02–16 License: GPL-3.0LibClock – Tamriel Standard Time Public functions to get information about the in-game time, date and moon You can call them directly or subscribe to updates.
Each function also gives the option to get information about a specific timestamp.
Functions
IsNotNilOrEmpty (obj) | Check if string is nil or empty |
IsTimestamp (timestamp) | Check if input is a timestamp |
IsLeapYear (year) | Test if the current year is a leap year |
GetWeekDay (table) | Calculate the week day based on a given year, month and day https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Gauss’s_algorithm |
Instance () | Instance of library You can either get a singleton instance, or create your custom instance with your specific delays. |
New (updateDelay, moonUpdateDelay[, countFullPhaseAsFull]) | Constructor Create a object to use custom delays between updates. |
GetTime ([timestamp]) | Get the lore time If a parameter is given, the lore time of the UNIX timestamp will be returned, otherwise it will be the current time. |
GetDate ([timestamp]) | Get the lore date If a parameter is given, the lore date of the UNIX timestamp will be returned, otherwise it will be calculated from the current time. |
GetMoon ([timestamp]) | Get the lore moon If a parameter is given, the lore moon of the UNIX timestamp will be returned, otherwise it will be calculated from the current time. |
Register (addonId, func) | Register an addon to subscribe to date and time updates. |
CancelSubscription (addonId) | Cancel a subscription for the date and time updates. |
RegisterForTime (addonId, func) | Register an addon to subscribe to time updates. |
CancelSubscriptionForTime (addonId) | Cancel a subscription for the time updates. |
RegisterForDate (addonId, func) | Register an addon to subscribe to date updates. |
CancelSubscriptionForDate (addonId) | Cancel a subscription for the date updates. |
RegisterForMoon (addonId, func) | Register an addon to subscribe to moon updates. |
CancelSubscriptionForMoon (addonId) | Cancel a subscription for the moon updates. |
Tables
CONSTANTS | Constants with all information about the time, date and moon |
time | Constant information to calculate the Tamriel Standard Time |
date | Constant information to calculate the Tamriel Standard Time date Eso Release was the 04.04.2014 at UNIX 1396569600 real time 93 days after 1.1.582 in-game |
date.monthLength | Different length of month within the year in days |
moon | Constant information to calculate the moon position |
moon.phasesPercentage | Percentage until end of phase from https://esoclock.uesp.net/ |
Local Functions
CalculateTST ([timestamp]) | Get the lore time If a parameter is given, the lore date of the UNIX timestamp will be returned, otherwise it will be the current time. |
CalculateTSTDate ([timestamp]) | Get the lore date If a parameter is given, the lore date of the UNIX timestamp will be returned, otherwise it will be calculated from the current time. |
GetCurrentPhaseName (phasePercentage) | Get the name of the current moon phase |
GetSecondsUntilFullMoon (phasePercentage) | Calculate the seconds until the moon is full again returns 0 if the moon is already full |
CalculateMoon (timestamp) | Calculate the lore moon |
Functions
- IsNotNilOrEmpty (obj)
-
Check if string is nil or empty
Parameters:
- obj string to be checked
Returns:
-
bool if it is not nil or empty
- IsTimestamp (timestamp)
-
Check if input is a timestamp
Parameters:
- timestamp object to be checked
Returns:
-
bool if it matches the condition
- IsLeapYear (year)
-
Test if the current year is a leap year
Parameters:
- year has to be an integer with the full year length
Returns:
-
bool if year is a leap year
- GetWeekDay (table)
-
Calculate the week day based on a given year, month and day
https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Gauss’s_algorithm
Parameters:
- table like {year = 2020, month = 2, day = 16}
Returns:
-
week day as a number from 1 (Monday) to 7 (Sunday)
- Instance ()
-
Instance of library
You can either get a singleton instance,
or create your custom instance with your specific delays.
Returns:
-
LibClockTST object
- New (updateDelay, moonUpdateDelay[, countFullPhaseAsFull])
-
Constructor
Create a object to use custom delays between updates.
Warning: Could lead to performance issues if you overdue this!
Parameters:
- updateDelay delays between two updates in ms to calculate the time and date
- moonUpdateDelay delays between two updates in ms to calculate the moon
- countFullPhaseAsFull is default false. It decides, if the whole full moon phase is counted as full (100%) or the phase is treated as any other. (optional)
Returns:
-
LibClockTST object
- GetTime ([timestamp])
-
Get the lore time
If a parameter is given, the lore time of the UNIX timestamp will be returned,
otherwise it will be the current time.
Parameters:
- timestamp UNIX timestamp in s (optional)
Returns:
time table
{ hour, minute, second }
See also:
- GetDate ([timestamp])
-
Get the lore date
If a parameter is given, the lore date of the UNIX timestamp will be returned,
otherwise it will be calculated from the current time.
Parameters:
- timestamp UNIX timestamp in s (optional)
Returns:
date table
{ era, year, month, day, weekDay }
See also:
- GetMoon ([timestamp])
-
Get the lore moon
If a parameter is given, the lore moon of the UNIX timestamp will be returned,
otherwise it will be calculated from the current time.
Parameters:
- timestamp UNIX timestamp in s (optional)
Returns:
moon table
{ percentageOfPhaseDone, currentPhaseName, isWaxing, isFull, percentageOfCurrentPhaseDone, secondsUntilNextPhase, daysUntilNextPhase, secondsUntilFullMoon, daysUntilFullMoon, percentageOfFullMoon }
See also:
- Register (addonId, func)
-
Register an addon to subscribe to date and time updates.
Parameters:
- addonId Id of the addon to be registered
- func function with two parameters for time and date to be called
See also:
- CancelSubscription (addonId)
-
Cancel a subscription for the date and time updates.
Will also stop background calculations if no addon is subscribing anymore.
Parameters:
- addonId Id of the addon previous registered
- RegisterForTime (addonId, func)
-
Register an addon to subscribe to time updates.
Parameters:
- addonId Id of the addon to be registered
- func function with a parameter for time to be called
See also:
- CancelSubscriptionForTime (addonId)
-
Cancel a subscription for the time updates.
Parameters:
- addonId Id of the addon previous registered
See also:
- RegisterForDate (addonId, func)
-
Register an addon to subscribe to date updates.
Parameters:
- addonId Id of the addon to be registered
- func function with a parameter for date to be called
See also:
- CancelSubscriptionForDate (addonId)
-
Cancel a subscription for the date updates.
Parameters:
- addonId Id of the addon previous registered
See also:
- RegisterForMoon (addonId, func)
-
Register an addon to subscribe to moon updates.
Parameters:
- addonId Id of the addon to be registered
- func function with a parameter for moon to be called
See also:
- CancelSubscriptionForMoon (addonId)
-
Cancel a subscription for the moon updates.
Parameters:
- addonId Id of the addon previous registered
See also:
Tables
- CONSTANTS
-
Constants with all information about the time, date and moon
Fields:
- time information to calculate the Tamriel Standard Time
- date information to calculate the Tamriel Standard Time date
- moon information to calculate the moon position
- time
-
Constant information to calculate the Tamriel Standard Time
Fields:
- lengthOfDay length of one day in s (default 5.75h right now)
- lengthOfNight length of only the night in s (2h)
- lengthOfHour length of an in-game hour in s
- startTime unix timestamp in s at in-game noon 1398044126 – 10477.5 (lengthOfDay/2)
- date
-
Constant information to calculate the Tamriel Standard Time date
Eso Release was the 04.04.2014 at UNIX 1396569600 real time
93 days after 1.1.582 in-game
Fields:
- startTime release – offset to midnight 2801.2760416667 – offset of days 1948815
- startWeekDay Start day Friday (5) – 93 days to 1.1. Therefore, the weekday is (4 – 93)%7
- startYear offset in years, because the game starts in 2E 582
- startEra era the world is in
- yearLength length of the in-game year in days
- leaps number of leaps in this era, assuming, that year 2E4 and 2E400 are leap years
- date.monthLength
-
Different length of month within the year in days
Fields:
- [1] Januar
- [2] Februar
- [3] March
- [4] April
- [5] May
- [6] June
- [7] July
- [8] August
- [9] September
- [10] October
- [11] November
- [12] December
- moon
-
Constant information to calculate the moon position
Fields:
- startTime start time calculated from https //esoclock.uesp.net/ values to be new moon
- phaseLength ingame days
- phaseLengthInSeconds in s, phaseLength * dayLength
- singlePhaseLength in ingame days
- singlePhaseLengthInSeconds in s, singlePhaseLength * dayLength
- phasesPercentageBetweenPhases length in percentage of whole phase of each single phase
- moon.phasesPercentage
-
Percentage until end of phase from https://esoclock.uesp.net/
Fields:
- [1]
- endPercentage
Local Functions
- CalculateTST ([timestamp])
-
Get the lore time
If a parameter is given, the lore date of the UNIX timestamp will be returned,
otherwise it will be the current time.
Parameters:
- timestamp UNIX timestamp in s (optional)
Returns:
time table
{ hour, minute, second }
- CalculateTSTDate ([timestamp])
-
Get the lore date
If a parameter is given, the lore date of the UNIX timestamp will be returned,
otherwise it will be calculated from the current time.
Parameters:
- timestamp UNIX timestamp in s (optional)
Returns:
date table
{ era, year, month, day, weekDay }
- GetCurrentPhaseName (phasePercentage)
-
Get the name of the current moon phase
Parameters:
- phasePercentage percentage already pased in the current phase
Returns:
-
current moon phase string
- GetSecondsUntilFullMoon (phasePercentage)
-
Calculate the seconds until the moon is full again
returns 0 if the moon is already full
Parameters:
- phasePercentage percentage already pased in the current phase
Returns:
-
number of seconds until the moon is full again
- CalculateMoon (timestamp)
-
Calculate the lore moon
Parameters:
- timestamp UNIX to be calculated from
Returns:
moon table
{ percentageOfPhaseDone, currentPhaseName, isWaxing, isFull, percentageOfCurrentPhaseDone, secondsUntilNextPhase, daysUntilNextPhase, secondsUntilFullMoon, daysUntilFullMoon, percentageOfFullMoon }