User Tools

Site Tools


dev:api:railway_time_api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
dev:api:railway_time_api [2019-06-20 11:33]
141.76.179.161 api part 1
dev:api:railway_time_api [2022-07-15 14:45] (current)
maverick2797 ↷ Page moved from usage:lines:railway_time_api to dev:api:railway_time_api
Line 1: Line 1:
 ====== Railway Time API ====== ====== Railway Time API ======
-These functions are accessible at+This is the documentation for the [[usage:lines:railway_time]] API. 
 +These functions are accessible for developers at:
   advtrains.lines.rwt.*   advtrains.lines.rwt.*
-  +These functions are also accessible in the LuaATC environment at: 
 +  rwt.*
 ===== Railway Time Formats ===== ===== Railway Time Formats =====
 A railway time can be represented by 3 different formats: table, string or seconds. All API functions accept any of the formats as input, and usually output in table form, unless specified otherwise. A railway time can be represented by 3 different formats: table, string or seconds. All API functions accept any of the formats as input, and usually output in table form, unless specified otherwise.
Line 17: Line 19:
 A time string can be either in the form cc;mm;ss or mm;ss. Trailing 0's can be omitted. A time string can be either in the form cc;mm;ss or mm;ss. Trailing 0's can be omitted.
 mm and ss must be within 0-60. mm and ss must be within 0-60.
-  1:23:45+  1;23;45
  
 ==== Seconds ==== ==== Seconds ====
Line 58: Line 60:
   The argument order is reverse to diff().   The argument order is reverse to diff().
  
-adjust_cycle(rwtime, reftime_p, thresh) +===== Repeating Times =====
-adjust(rwtime, reftime, thresh)+
  
-adj_diff(t1t2thresh)+Sometimes, you need to work with times like "at 15;30 every cycle" or "every two minutes". Such expressions are called "repeating time". They are characterized by an interval ("every ii;ii") and an offset ("at oo;oo"). 
 + 
 +Example: The times 05;00 25;00 45;00 would be expressed by interval 20;00, offset 05;00. 
 + 
 +  time_to_next_rpt(rwtime, rpt_interval, rpt_offset) 
 +  Returns number of seconds until this repeating time occurs the next time 
 + 
 +  time_from_last_rpt(rwtime, rpt_interval, rpt_offset) 
 +  Returns number of seconds until this repeating time occured the last time 
 + 
 +  last_rpt(rwtime, rpt_interval, rpt_offset) 
 +  Returns time when this repeating time occured the last time 
 + 
 +  next_rpt(rwtimerpt_intervalrpt_offset) 
 +  Returns time when this repeating time occurs the next time
  
-get_time_until(deptime, rwtime_p) 
  
-time_to_next_rpt(rwtime, rpt_interval, rpt_offset) 
-time_from_last_rpt(rwtime, rpt_interval, rpt_offset) 
-next_rpt(rwtime, rpt_interval, rpt_offset) local rwtime_s = rwt.to_secs(rwtime) local rpti_s = last_rpt(rwtime, rpt_interval, rpt_offset) 
dev/api/railway_time_api.1561023227.txt.gz · Last modified: 2019-06-20 11:33 by 141.76.179.161