Skip to content

Sh031224/time-counting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

time-counting

Travis ci Github issues Githug stars Github license Downloads Npm version
📦 A package that lets you know how many days before that date.

Korean

Installation

You Can install by npm

$ npm install time-counting --save

or yarn

$ yarn add time-counting

Usage

Javascript

// es5
const TimeCounting = require("time-counting");
const time = TimeCounting("2020-08-10");
const timecount = TimeCounting("2020-08-10 08:00:00", {
  objectTime: "2020-08-10 10:00:00"
});

//es6
import TimeCounting from "time-counting";
console.log(TimeCounting("2020-08-10"));
console.log(TimeCounting("2020-08-10 08:00:00", { objectTime: "2020-08-10 10:00:00" }));
Output should be how long it is and how much is left from the current time.
2 hours ago

TypeScript

import TimeCounting from "time-counting";
console.log(TimeCounting("2020-08-10", { objectTime: "2020-08-11" }));
1 day ago

Options

Name Value default description
objectTime Date, string, number new Date() It is a standard time for comparison.
lang "ko", "en" "en" language
calculate Calculate Calculate Choose how far you want the time to appear.

Calculate

Name Value default Unit
justNow number 20 second
second number 60 second
minute number 60 minute
hour number 24 hour
day number 7 day
week number 4 week
month number 12 month

Example

const option = {
  objectTime: "2020-08-10 06:00:00",
  calculate: {
    justNow: 3601
  }
};
console.log(TimeCounting("2020-08-10 05:00:00", option));
just now

💬 Up to 1 hour 1 second is displayed as "just now".

Testing

npm run test