Advertisement
SReject

$ConvertTwitchTime

Jan 18th, 2016
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.12 KB | None | 0 0
  1. /*
  2.   To get the date use $asctime(), for example:
  3.       $asctime($ConvertTwitchTime(<date-time field here>), mmm dd yyyy HH:nn:ss)
  4.  
  5.   To get the seconds-since use subtract from $ctime
  6.       $calc($ctime - $ConvertTwitchTime(<date-time field here>))
  7.  
  8.   To get the time-since in something a bit more readable, use $duration
  9.       $duration($calc($ctime - $ConvertTwitchTime(<date-time field here>)))
  10. */
  11.  
  12.  
  13. ;; coverts a twitch date-time field into a UTC epoch integer
  14. alias ConvertTwitchTime {
  15.   if ($regex($1-, /^(\d\d(?:\d\d)?)-(\d\d)-(\d\d)T(\d\d)\:(\d\d)\:(\d\d)(?:(?:Z$)|(?:([+-])(\d\d)\:(\d+)))?$/i)) {
  16.     var %m = $Gettok(January February March April May June July August September October November December, $regml(2), 32), %d = $ord($base($regml(3),10,10)), %o = +0, %t
  17.     if ($regml(0) > 6) %o = $regml(7) $+ $calc($regml(8) * 3600 + $regml(9))
  18.     %t = $calc($ctime(%m %d $regml(1) $regml(4) $+ : $+ $regml(5) $+ : $+ $regml(6)) - %o)
  19.     if ($asctime(zz) !== 0 && $regex($v1, /^([+-])(\d\d)(\d+)$/)) {
  20.       %o = $regml(1) $+ $calc($regml(2) * 3600 + $regml(3))
  21.       %t = $calc(%t + %o )
  22.     }
  23.     return %t
  24.   }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement