[notabug] GetAchievementTimestamp(number achievementId) returns wrong datatype - ESOUI
Thread Tools Display Modes
12/06/21, 09:18 AM   #1
AddOn Author - Click to view addons
Join Date: Nov 2019
Posts: 2
[notabug] GetAchievementTimestamp(number achievementId) returns wrong datatype

Hello everyone,

I noticed the function "GetAchievementTimestamp(number achievementId)" returns "wrong" values.
For my understanding the function expects a number, the id of an achievement, and should return a unix timestamp of the completion date of the given achievement or 0 if it hasn't been completed.

Calling the function for completed achievements however, the return value is a floating point number.

I did some investigation with the number the function returned: In my example, the returned number was "7.8484867882774e-315". The 64 bits of that double are "0000000000000000000000000000000001011110101011110101111011110011". When you interpret these bits as an unsigned long you get the value "1588551411", which is the actual unix timestamp of completion of the achievement I fed into the function, May 4th 2020.

Seems like the lua backend just interprets the memory as the wrong data type so the issue should be easily fixable trough some pointer-casting-magic

Unfortunatly I am unable to tell if this is a recent bug or if it has been in the game for longer.

I hope this is helpful for the devs
12/06/21, 10:08 AM   #2
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,503
That's not a bug and was actually discussed on gitter a few weeks ago.
To clarify, the documentation states that the return type is an id64 which only looks like a number, but is actually some ESO specific black magic to bring 64 bit integers to Lua:
* GetAchievementTimestamp(*integer* _achievementId_)
** _Returns:_ *id64* _timestamp_
It works differently and can only be used with certain functions that accept id64 as input, like Id64ToString:
* Id64ToString(*id64* _id_)
** _Returns:_ *string* _stringDesc_
The actual bug is that GetTimeStamp also states that it returns an id64, when in reality it returns a regular Lua number. Due to it working like that since launch and almost every addon relying on GetTimeStamp returning a 32bit integer, they won't change the type of that and will instead update the documentation to state the correct return type next update.
https://www.imperialtradingcompany.eu/ - My Addons - The Vault (Early updates and experimental projects) - My patreon - My blog
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.

ESOUI » Developer Discussions » Bug Reports » [notabug] GetAchievementTimestamp(number achievementId) returns wrong datatype

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off