GithubHelp home page GithubHelp logo

steven-varga / clock Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 65 KB

Home Page: http://clock.vargaconsulting.ca

License: Other

Makefile 16.32% CSS 26.50% JavaScript 45.07% HTML 12.10%
chrono cpp date-time

clock's Introduction

This header only library is build on top of Howard Hinnan's date-time templates, wraps the underlying representation and provides conversion between std::chrono::system_clock and R/.NET/Windows clocks.

Concepts:

Epoch is the reference point time is counted from. The actual value is the representation, and the resolution or the smallest tick of the clock is the period. Time is measured in duration and may or may not be tied to an epoch. The epoch, duration, period and representation define a clock. Clock tells the current time: SomeClock<std::chrono::milliseconds>::now() and may provide means of conversion to other clocks. Provided the right conversion one can tap into Howard Hinnan's calandar and time-zone parsing/printing library: date-time. This library provides conversions between std::chrono::system_clock and R/.NET/Windows clocks.

internally uses IEEE 754 double precision float, storing fractional seconds in mantissa. This format allows missing values as NAN-s , and to define arbitrary epoch called origin. The roundoff error inherent in floats discussed on stack overflow.

Here are the planned templates to represent POSIXct type with C++11 chrono compatible templates:

using RClock = chrono::Clock< date::year{1970}/date::month{1}/date::day{1}, 	// epoch
				std::chrono::duration<double,std::ratio<1>> >;  				// representation and resolution

Use <date/tz.h> IO formatting function:

	std::cout 
	<< RClock::now()            
	<< date::format("%a %b %d, %Y", RClock::now() );

Lifted from the website: A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond, or 10 million ticks in a second. The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001 (0:00:00 UTC on January 1, 0001, in the Gregorian calendar), which represents DateTime::MinValue.

has been around on POSIX systems, conversion is supported between chrono and time_t. The fact that there is no guaranteed underlying representation, and no sub-second resolution makes it less suitable for Real Time Bidding, High Frequency Trading.

To find out the underlying type:

echo | gcc -E -xc -include 'time.h' - | grep time_t

On my system I get typedef long int __time_t same as you find on .NET with the difference in resolution, and epoch.

BOOST Time

TODO:

  • research date-time representations
  • should boost to date.h conversions be supplied

clock's People

Contributors

steven-varga avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.