mIRC Homepage
Posted By: HelpPlease Timestamp in MS - 06/07/20 08:35 PM
Hi, I need some help. Is it possible in Mirc to configure a script so that the timestamp can display down to MS. My current display is HH:MM:SS I have read & searched the forum & found some old threads with suggestions but I am simply unable to get any of them to work.
I am totally new to Mirc & am just copying the code verbatim into the Script editor under the Aliases heading then saving it.
The thread I was looking at is https://forums.mirc.com/ubbthreads....e/timestamp-with-milliseconds#Post142551
Any help at all would be hugely appreciated.
Posted By: Dazuz Re: Timestamp in MS - 07/07/20 08:40 PM
Code
on *:start:timestampfix

alias timestampfix {
  set -l %c $ctime + 1
  while (%c > $ctime) noop
  set -e %ticksoffset $ticks % 1000
  .timertimestamp -om 0 0 .timestamp -f HH:nn:ss. $!+ $!right($calc($ticks -%ticksoffset),3)
}

Press ALT+R to open remote, paste the code in, press OK and type "/timestampfix". In future it will automatically active when mIRC starts, so you don't need to type "/timestampfix" ever again.

To uninstall it, remove the code, type "/.timertimestamp off" and then type "/timestamp -f HH:nn:ss" to restore normal timestamp format.

If you want to change the timestamp format, you need to change the last line of the "timestampfix" alias. When you've changed it, you need to use the "/timestampfix" command, or restart mIRC.


Just to give you a couple of examples:

.timertimestamp -om 0 0 .timestamp -f yyyy-mm-dd HH:nn:ss. $!+ $!right($calc($ticks -%ticksoffset),3)
Would result in: 2020-07-07 12:34:56.789

.timertimestamp -om 0 0 .timestamp -f [HH:nn:ss. $!+ $!right($calc($ticks -%ticksoffset),3) $!+ ]
Would result in: [12:34:56.789]

/help $asctime might help.
Posted By: Dazuz Re: Timestamp in MS - 08/07/20 11:41 AM
Got bored and took it a couple steps further. Ignore the first post.


Installation
  • Press ALT+R to open remote.
  • Paste in the code and press OK.
  • Use "/timestampfix" command.
    This command can also be used to fix any sync or whatever issues.


Uninnstallation
  • Remove the code.
  • Use "/timertimestamp off" command.
  • Use "/timestamp -f HH:nn:ss" command to restore normal timestamp format.



If you switch between scripts, remember to use the /timestampfix command.


Simplest script with the best performance. If you want nothing fancy, this is it.

To change the timestamp format, you need to edit the ".timertimestamp..." line, specifically the part after "-f".

Examples:

.timertimestamp -om 0 0 .timestamp -f HH:nn:ss. $!+ $!right($calc($ticks - $+ $calc($ticks % 1000) $+ ),3)
Would result in: 12:34:56.789

.timertimestamp -om 0 0 .timestamp -f yyyy-mm-dd HH:nn:ss. $!+ $!right($calc($ticks - $+ $calc($ticks % 1000) $+ ),3)
Would result in: 2020-07-07 12:34:56.789

.timertimestamp -om 0 0 .timestamp -f [HH:nn:ss. $!+ $!right($calc($ticks - $+ $calc($ticks % 1000) $+ ),3) $!+ ]
Would result in: [12:34:56.789]

After you've changed the timer command, use "/timestampfix" command.
Code
on *:start:timestampfix

alias timestampfix {
  tokenize 1 $ctime
  while ($1 == $ctime) noop
  .timertimestamp -om 0 0 .timestamp -f HH:nn:ss. $!+ $!right($calc($ticks - $+ $calc($ticks % 1000) $+ ),3)
}




Fancy advanced version with a little performance impact. THIS VERSION CAN BREAK OTHER SCRIPTS, if echo alias is used.

Code
/*
timestampformat alias is the only part of the script you might
need to modify, specifically the part after the word "return".

Examples:
HH:nn:ss. $+ $timems
$+([HH:nn:ss.,$timems,])
yyyy-mm-dd HH:nn:ss. $+ $timems

/help $asctime
/help $+
*/
alias timestampformat return HH:nn:ss. $+ $timems

/*
echo alias is optional. It is only needed if you want the millisecond
timestamp to update in the middle of other scripts that use echo, but:
THIS CAN POTENTIALLY BREAK OTHER SCRIPTS.

To see the difference, use the following command with and without the echo alias.
//set -l %x 100 | while (%x) { echo -t <-- | dec %x }
*/
alias echo {
  if (-*t* iswmcs $1) {
    set -l %t $asctime($timestampformat)
    !echo $iif($removecs($1,t) != -,$v1) $iif($window($2),$2 %t $3-,%t $2-)
  }
  else !echo $1-
}

alias timems return $right($calc($ticks -%ticksoffset),3)

on *:start:timestampfix

alias timestampfix {
  set -l %c $ctime + 1
  while (%c > $ctime) noop
  set -e %ticksoffset $ticks % 1000
  .timertimestamp -om 0 0 .timestamp -f $!timestampformat
}




Mostly same as above, but with potentially increased precision from 16 ms to 1 ms. Slightly worse performance. THIS VERSION CAN BREAK OTHER SCRIPTS, if echo alias is used.

This version requires a custom time.dll in mIRC folder (//run $mircdir) to function.

The increased precision only applies to /echo commands, there is no reasonable to way to increase the precision of the other part of the script. You could potentially get a tiny bit more precision out of it by changing ".timertimestamp -om" into ".timertimestamp -oh", but it is not recommended.
Code
/*
timestampformat alias is the only part of the script you might
need to modify, specifically the part after the word "return".

Examples:
HH:nn:ss. $+ $timems
$+([HH:nn:ss.,$timems,])
yyyy-mm-dd HH:nn:ss. $+ $timems

/help $asctime
/help $+
*/
alias timestampformat return HH:nn:ss. $+ $timems

/*
echo alias is optional. It is only needed if you want the millisecond
timestamp to update in the middle of other scripts that use echo, but:
THIS CAN POTENTIALLY BREAK OTHER SCRIPTS.

To see the difference, use the following command with and without the echo alias.
//set -l %x 100 | while (%x) { echo -t <-- | dec %x }
*/
alias echo {
  if (-*t* iswmcs $1) {
    set -l %t $asctime($timestampformat)
    !echo $iif($removecs($1,t) != -,$v1) $iif($window($2),$2 %t $3-,%t $2-)
  }
  else !echo $1-
}

alias timems return $right($calc($dll(time.dll,ticks,0)-%ticksoffset),3)

on *:start:timestampfix

alias timestampfix {
  set -l %c $ctime + 1
  while (%c > $ctime) noop
  set -e %ticksoffset $dll(time.dll,ticks,0) % 1000
  .timertimestamp -om 0 0 .timestamp -f $!timestampformat
}

Posted By: HelpPlease Re: Timestamp in MS - 09/07/20 03:13 PM
Thank you so much for the help & how to. This works perfectly for me. Genuine thank you, really appreciate you taking the time to reply. grin
© mIRC Discussion Forums