-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…e npm package. Added type qualifier to most type and interface imports to improve tree-shaking. Updated README format with additional package details + new badge format. Upgraded dependencies to latest including @toreda/log and @toreda/types.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
demo | ||
node_modules | ||
tests | ||
docs | ||
*.code-workspace | ||
coverage | ||
yarn-debug.log | ||
yarn-error.log | ||
test-report.xml | ||
.eslintrc.js | ||
.gitattributes | ||
.github | ||
.vscode | ||
sonar-project.properties | ||
.prettierrc.js | ||
.eslintrc.js | ||
.vscode | ||
*.code-workspace | ||
coverage/ | ||
demo/ | ||
docs/ | ||
examples/ | ||
gulpfile.ts | ||
jest.config.js | ||
node_modules | ||
sonar-project.properties | ||
src/ | ||
test-report.xml | ||
tests | ||
tsconfig.json | ||
./src/ | ||
examples/ | ||
yarn-debug.log | ||
yarn-error.log |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,96 @@ | ||
|
||
[![Toreda](https://content.toreda.com/logo/toreda-logo.png)](https://www.toreda.com) | ||
|
||
[![CI](https://img.shields.io/github/workflow/status/toreda/time/CI?style=for-the-badge)](https://github.com/toreda/time/actions) [![Coverage](https://img.shields.io/sonar/coverage/toreda_time?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge)](https://sonarcloud.io/project/activity?graph=coverage&id=toreda_time) [![Sonar Quality Gate](https://img.shields.io/sonar/quality_gate/toreda_time?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge)](https://sonarcloud.io/dashboard?id=toreda_time) | ||
|
||
[![GitHub package.json version (branch)](https://img.shields.io/github/package-json/v/toreda/time/master?style=for-the-badge)](https://github.com/toreda/time/releases/latest) [![GitHub Release Date](https://img.shields.io/github/release-date/toreda/time?style=for-the-badge)](https://github.com/toreda/time/releases/latest) [![GitHub issues](https://img.shields.io/github/issues/toreda/time?style=for-the-badge)](https://github.com/toreda/time/issues) | ||
|
||
[![license](https://img.shields.io/github/license/toreda/time?style=for-the-badge)](https://github.com/toreda/time/blob/master/LICENSE) | ||
|
||
| ||
# `@toreda/time` | ||
Fast & easy time math and time unit conversions. | ||
|
||
![CI](https://github.com/toreda/time/workflows/CI/badge.svg?branch=master) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=toreda_time&metric=coverage)](https://sonarcloud.io/dashboard?id=toreda_time) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=toreda_time&metric=alert_status)](https://sonarcloud.io/dashboard?id=toreda_time) | ||
| ||
|
||
Helpers for common time & timer functionality. | ||
## Use Cases | ||
* **Time since date** | ||
* Get seconds or any other time unit since `date`, `datetime`, `timestamp`, or `unix timestamp`. | ||
* **Time until date** | ||
* Get seconds or other time unit until `date`, `datetime`, `timestamp`, or `unix timestamp`. | ||
* **Now** | ||
* Get current timestamp (now) in seconds or other time unit. | ||
* **Now (with offset)`** | ||
* Get current timestamp (now) with an offset in the past or future. | ||
* **DateTime Parsing** | ||
* Parse strings as `DateTime` strings. | ||
* Convert to any other time unit. | ||
* **Unix Timestamps** | ||
* Parse `Unix Timstamps` (seconds) & convert to other time units. | ||
* Convert `DateTime` strings to `Unix Timestamp`. | ||
|
||
| ||
|
||
# Install | ||
`@toreda/time` is available as an [NPM package](https://www.npmjs.com/package/@toreda/time). | ||
## Highlights | ||
* **TypeScript Native** | ||
* All types included with package. | ||
* No separate `@types` package eliminates sync issues between types and the library. | ||
* **Minimalist** | ||
* Small set of library functions for time calculations. | ||
* Get what you need without extra bloat. | ||
* **Lightweight** | ||
* **`253 kB`** unpacked. | ||
* **Modern Alternative** | ||
* Modern replacement for the excellent [`moment.js`](https://momentjs.com/docs/#/-project-status/) (no longer maintained). | ||
* **Tree-Shaking** | ||
* Package optimizations helps modern bundlers drop unused code. | ||
|
||
| ||
|
||
**Install with yarn:** | ||
# Install | ||
|
||
## `npmjs.org` | ||
|
||
## NPM Package | ||
`@toreda/time` is available as an [NPM package](https://www.npmjs.com/package/@toreda/time). | ||
### Yarn Install (preferred) | ||
```bash | ||
yarn add @toreda/time | ||
``` | ||
|
||
**or Install with NPM:** | ||
### NPM Install | ||
```bash | ||
npm install @toreda/time | ||
``` | ||
|
||
| ||
# Source Code | ||
`@toreda/time` source files can be downloaded directly from the public [Github repo](https://github.com/toreda/time). | ||
## Branches | ||
* `master` branch | ||
* Latest release & stable code. | ||
* Use for production builds. | ||
* `develop` branch | ||
* All completed but unreleased features pending release. | ||
* Generally stable, but not guaranteed. | ||
* Not suitable for production builds. | ||
|
||
## Git Clone (ssh) | ||
```bash | ||
[email protected]:toreda/time.git | ||
``` | ||
|
||
## Git Clone (https) | ||
```bash | ||
https://github.com/toreda/time.git | ||
``` | ||
|
||
## Download Zip (https) | ||
Download the current master branch as a zip file | ||
```https://github.com/toreda/time/archive/refs/heads/master.zip``` | ||
|
||
| ||
|
||
# Usage | ||
|
||
## Time Objects | ||
|
@@ -127,10 +193,12 @@ console.log('is valid: ' + timeValid(undefined)); | |
# Legal | ||
|
||
## License | ||
|
||
[MIT](LICENSE) © Toreda, Inc. | ||
|
||
|
||
## Copyright | ||
Copyright © 2019 - 2021 Toreda, Inc. All Rights Reserved. | ||
Copyright © 2019 - 2022 Toreda, Inc. All Rights Reserved. | ||
|
||
|
||
https://www.toreda.com | ||
## Website | ||
Toreda's company website can be found at [toreda.com](https://www.toreda.com) |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>TimerOptions | @toreda/time</title><meta name="description" content="Documentation for @toreda/time"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@toreda/time</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label><input type="checkbox" id="tsd-filter-externals" checked/><label class="tsd-widget" for="tsd-filter-externals">Externals</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@toreda/time</a></li><li><a href="TimerOptions.html">TimerOptions</a></li></ul><h1>Interface TimerOptions</h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead"> | ||
<p>Configuration options provided to timer constructors.</p> | ||
</div></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">TimerOptions</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-interface"><a href="TimerOptions.html#limitDuration" class="tsd-kind-icon">limit<wbr/>Duration</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="TimerOptions.html#timeLimit" class="tsd-kind-icon">time<wbr/>Limit</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="limitDuration" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagOptional">Optional</span> limit<wbr/>Duration</h3><div class="tsd-signature tsd-kind-icon">limit<wbr/>Duration<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/toreda/time/blob/f379e2a/src/timer/options.ts#L7">timer/options.ts:7</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface"><a id="timeLimit" class="tsd-anchor"></a><h3><span class="tsd-flag ts-flagOptional">Optional</span> time<wbr/>Limit</h3><div class="tsd-signature tsd-kind-icon">time<wbr/>Limit<span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/toreda/time/blob/f379e2a/src/timer/options.ts#L8">timer/options.ts:8</a></li></ul></aside></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../modules.html">Exports</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-interface"><a href="TimerOptions.html" class="tsd-kind-icon">Timer<wbr/>Options</a><ul><li class="tsd-kind-property tsd-parent-kind-interface"><a href="TimerOptions.html#limitDuration" class="tsd-kind-icon">limit<wbr/>Duration</a></li><li class="tsd-kind-property tsd-parent-kind-interface"><a href="TimerOptions.html#timeLimit" class="tsd-kind-icon">time<wbr/>Limit</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private property</span></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html> |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {Time} from './time'; | ||
import type {Time} from './time'; | ||
import {timeMake} from './time/make'; | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {Time} from './time'; | ||
import type {Time} from './time'; | ||
import {timeMake} from './time/make'; | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {Time} from './time'; | ||
import type {Time} from './time'; | ||
import {timeMake} from './time/make'; | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {Time} from './time'; | ||
import type {Time} from './time'; | ||
import {timeMake} from './time/make'; | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {Time} from './time'; | ||
import type {Time} from './time'; | ||
import {timeMake} from './time/make'; | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {TimeUnit} from '../unit'; | ||
import type {TimeUnit} from '../unit'; | ||
|
||
/** | ||
* @category Time Units | ||
|