mIRC Home    About    Download    Register    News    Help

Print Thread
Timestamp in MS #267448 06/07/20 08:35 PM
Joined: Jul 2020
Posts: 3
H
HelpPlease Offline OP
Self-satisfied door
OP Offline
Self-satisfied door
H
Joined: Jul 2020
Posts: 3
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.

Re: Timestamp in MS [Re: HelpPlease] #267452 07/07/20 08:40 PM
Joined: Dec 2015
Posts: 145
Dazuz Offline
Vogon poet
Offline
Vogon poet
Joined: Dec 2015
Posts: 145
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.

Last edited by Dazuz; 07/07/20 09:49 PM. Reason: brainfart
Re: Timestamp in MS [Re: Dazuz] #267453 08/07/20 11:41 AM
Joined: Dec 2015
Posts: 145
Dazuz Offline
Vogon poet
Offline
Vogon poet
Joined: Dec 2015
Posts: 145
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
}


Last edited by Dazuz; 08/07/20 01:48 PM. Reason: made the whole post more coherent.
Re: Timestamp in MS [Re: Dazuz] #267461 09/07/20 03:13 PM
Joined: Jul 2020
Posts: 3
H
HelpPlease Offline OP
Self-satisfied door
OP Offline
Self-satisfied door
H
Joined: Jul 2020
Posts: 3
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