Description

A simple countdown timer

Package Information

Version 0.3.0 (2016-Dec-14)
Repository https://github.com/o3o/timer
License Boost
Copyright Copyright © 2016, Orfeo Da Viá
Authors Orfeo Da Viá
Registered by Orfeo Da Via'
Sub packages
timer:countdown
Simple countdown timer example
timer:stopwatch
Simple stopwatch timer example
Dependencies none

Installation

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

dub.json
dub.sdl

Readme

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

Available versions

0.3.0 0.2.0 0.1.0 ~master