From 0325c5d93039504cd0f8b300353c890c71be3caa Mon Sep 17 00:00:00 2001 From: Matt Preucil Date: Mon, 28 Nov 2016 21:50:35 -0800 Subject: [PATCH] Update README.md --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index 9f0dbeb..b0a30a2 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,43 @@ A small utility to handle mach_absolute_time and timestamps. [![GitHub release](https://img.shields.io/github/release/randymarsh77/time.svg)]() [![SPM](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager) [![Build Status](https://api.travis-ci.org/randymarsh77/time.svg?branch=master)](https://travis-ci.org/randymarsh77/time) +[![codecov.io](https://codecov.io/gh/randymarsh77/time/branch/master/graphs/badge.svg)](https://codecov.io/gh/randymarsh77/time/branch/master) [![codebeat badge](https://codebeat.co/badges/bbf19ae9-35d5-4eb5-a47f-561480300607)](https://codebeat.co/projects/github-com-randymarsh77-time) + +# Usage + +Create some time +``` +let now = Time.Now +``` + +Get the mach value +``` +let mach = now.machTimeStamp +``` + +Create some time with a mach value +``` +_ = time.FromMachTimeStamp(mach) +``` + +Add a second +``` +let aSecondFromNow = now + Time(value: 1, unit: .Seconds) +``` + +Subtract some micros +``` +_ = aSecondFromNow - Time(value: 1234, unit: .Microseconds) +``` + +Compare +``` +_ = aSecondFromNow == now +_ = aSecondFromNo != now +``` + +Make a second +``` +aSecond = aSecondFromNow - now +```