Skip to content

Instantly share code, notes, and snippets.

@PetarKirov
Last active January 28, 2021 08:29
Show Gist options
  • Save PetarKirov/090e7fb9c2a919203065bf91f327a949 to your computer and use it in GitHub Desktop.
Save PetarKirov/090e7fb9c2a919203065bf91f327a949 to your computer and use it in GitHub Desktop.
Relative timestamp filter program in D
void main()
{
import core.time : MonoTime;
import std.stdio : stdin, writef;
import std.string : wrap;
const start = MonoTime.currTime;
foreach (line; stdin.byLineCopy)
{
const now = MonoTime.currTime;
const diff = now - start;
const indent = " ";
"[%+7s] %s".writef(diff.total!"msecs", line.wrap(80, "", indent));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment