Guest User

Phantom Isles Time API

a guest
Nov 24th, 2025
76
0
13 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // You would need to send a json formated timeRequest Object:
  2. @serializable
  3. class timeRequest {
  4. /**
  5.  * A Unix timestamp in ms of the time that shall be converted.
  6.  * For the current time you can use `Date.now();`
  7.  */
  8. timestamp: i64 /*ms*/ = 0;
  9. /**
  10.  * There are several supported formats but only the `json` format can be parsed as a PITDate object.
  11.  * Other supported formats are:
  12.  * Currently only 24h format is supported!
  13.  *
  14.  * "iso"                : 2025-02-29T15:37
  15.  * "date"               : 2025-02-29
  16.  * "dd.mm.yyyy"         : 29.02.2025
  17.  * "mm.dd.yyyy"         : 02.29.2025
  18.  * "dd.mm.yyyy hh:mm"   : 29.02.2025 15:37
  19.  * "mm.dd.yyyy hh:mm"   : 02.29.2025 15:37
  20.  * "longdate"           : 29. February 2025
  21.  * "longdate3"          : 29. Feb. 2025
  22.  * "longus"             : February 29, 2025
  23.  * "longus3"            : Feb. 29, 2025
  24.  * "longdatetime"       : 29. February 2025 15:37
  25.  * "longdatetime3"      : 29. Feb. 2025 15:37
  26.  * "longustime"         : February 29, 2025 15:37
  27.  * "longustime3"        : Feb. 29, 2025 15:37
  28.  * "compact"            : 202502291537
  29.  *  "json"              : JSON fromated PITDate Object
  30.  *  "full"              : 2025-02-29 15:37
  31.  *
  32.  * @property {string} format
  33.  */
  34. format: string = 'json';
  35. /**
  36.  * The type of leap year fix.
  37.  *
  38.  * This can be either `patched` or `aligned`.
  39.  * "date"               : 2025-02-29
  40.  * **patched**
  41.  * Means that there will be 1 extra day in February each leap year which will cause an offset of 4h (in PIT 1h = 50min)
  42.  * This will be fixed by adding another leap day every 5th year. (so 2 extra days in Feb).
  43.  *
  44.  * **aligned**
  45.  * This will also add a leapday every leap year but to avoid the offsetthe leapday will be 4 PIT hours longer.
  46.  * When using this time please refer to it as Phantom Isles Aligned Time (PIAT).
  47.  *
  48.  * @property {string} type
  49.  */
  50. type: string = 'patched';
  51. }
  52. /* together with the `getTime` topic.
  53. You will then recieve a JSON-formated `PITDate` object: */
  54. @serializable
  55. class PITDate {
  56.   /** Year (i16) */
  57.   year: i16 = 1970;
  58.   /** Month (i8; 1-12) */
  59.   month: i8 = 1;
  60.   /** Day (i8; 1-based) */
  61.   day: i8 = 1;
  62.   /** Hour (i8; 0-based) */
  63.   hour: i8 = 0;
  64.   /** Minute (i8; 0-based) */
  65.   minute: i8 = 0;
  66.   /** Original unix timestamp (i64, ms) */
  67.   timestamp: i64 = 0;
  68. }
  69.  
  70. /* Example: */
  71. const PIT_SCRIPT = 'PITScriptAdress'; /*Contact me if you want to use it.*/
  72.  
  73. function getPITTime(time: i64): PITDate|false {
  74.     /* !!!! To check if this is even used and how frequently I DO log requests and their scripts adresses. !!!! */
  75.     const req = Script.request(script,'getTime', `{"timestamp": ${now}, 'format': 'json', 'type': 'patched'}`);
  76.     if (req.is_error) {/* Do your Error handling here.*/ return false;} else {
  77.         return JSON.parse<PITDate>(req);
  78.     }
  79. }
  80.  
  81. const now = Date.now();
  82. const PIT = getPITTime(now);
  83. /*Now do whatever you want with that time. ^w^*/
  84.  
  85. /*Signed: Felinex Gloomfort*/
Advertisement
Add Comment
Please, Sign In to add comment