timer 0.4.1

A simple countdown timer


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

This package provides sub packages which can be used individually:

timer:countdown - Simple countdown timer example

timer:stopwatch - Simple stopwatch timer example


Dub version Build Status Dub download Status

timer

A simple D implementation of countdown and stopwatch timer

Usage

StopWatchTimer

import core.thread;
import std.stdio;

import timer;

void main(string[] args) {
   StopWatchTimer sw;
   sw.start();
   Thread.sleep(dur!("msecs")(200));
   sw.stop();
   writefln("elapsed %s", sw.elapsed);

   sw.reset();
   writefln("after reset elapsed %d ms", sw.elapsedMsecs);

   writeln();
   writeln("restart...");
   sw.restart();
   Thread.sleep(dur!("msecs")(150));
   writefln("After restart elapsed %d ms", sw.elapsedMsecs);
}

CountdownTimer

import core.thread;
import std.stdio;

import timer;

void main(string[] args) {
   Countdown countms;
   countms.start(200);
   while (!countms.isOver) {
      Thread.sleep(dur!("msecs")(10));
      writefln("elapsed %7.3f ms remaining %7.3f ms", countms.elapsedTime, countms.remainingTime);
   }
}

Examples can be found in the examples directory, and ran with dub run timer:stopwatch or dub run timer:countdown or finally with make:

$ cd examples
$ make

Libraries

License

Distributed under the Boost Software License, Version 1.0

Authors:
Orfeo Da Viá
Sub packages:
timer:countdown, timer:stopwatch
Dependencies:
none
Versions:
0.4.1 2017-Jul-26
0.4.0 2017-Jul-25
0.3.0 2016-Dec-14
0.2.0 2016-Nov-05
0.1.0 2016-Nov-02
Show all 6 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 2 downloads this month

  • 94 downloads total