femtofiber
femtofiber is immutable date library for JavaScript.
How to install
Without Node.js(for browsers)
Download a zip file from GitHub release page,
and unzip it.
Then you can see femtofiber.min.js
in build
directory.
Copy femtofiber.min.js
file to your project directory.
Import the file in your HTML as following:
With Node.js(for server)
Run npm install
.
npm install femtofiber --save
And import it.
import { Femto, Duration } from 'femtofiber';
Basic Usage
Creating Femto
You can create a Femto
object in several ways.
const femto1 = 2018 6 22; // from numbersconst femto2 = 2018 6 22 21 54 31 500; // from numbers with timeconst femto3 = Femto; // from Dateconst femto4 = Femto; // from current dateconst femto5 = Femto; // from epoch time
A Femto
object is immutable, so once created, its value does not change.
Properties
To get values, use properties.
const femto = Femto;console;console; // January is 1, and December is 12console;console;console;console;console;
Formatting string
A Femto
object also can output formatted string.
const femto = Femto;console; // "2018/06/22"console; // "18:23:27:758"
Calculation
A Femto
object has manipulating methods. You can manipulate date with Duration
objects.
const tomorrow = Femto;const yesterday = Femto;
To create a Duration
object, pass values to Duration
's constructor.
const duration = days: 4 hours: 7 minutes: 13 seconds: 6 milliseconds: 219;
Comparison
You can also compare two Femtos.
const current = 1529665309363;const femto1 = Femto;const femto2 = Femto; // These methods return boolean.femto1;femto1;femto1;femto1;femto1; Femto;Femto;
API document
For more information, see API Document.
License
MIT License. See LICENSE.md.