passed-time

1.1.0 • Public • Published

PASSED-TIME

Welcom

This is a simple module that allow you to get the difference between two time left from a previous past time to now. eg:2minleft this module support es5 and es2015

Introduction

The idea is to allow with a simple module be able to get the interval of time that left from a previous time until now.

  • whats you can do with

    • you can get how much times left form a previus time untill now
    • you can get the inteval of time according to a defined time such as thisweek, lastweek,days of this month
  • whats it can do. apart from those module, other expected are not avaible.

Installation

    npm install time-passed

Integration

The module is very easy to use.

  • step one : Date Format you need to have a date with this formatY-M-dd eg: 2020-12-15 and if there is time the following format is required to avoid crash, Y-M-dd h:m:s eg 2020-12-15 15:40:00.

  • step two : integration include the module and form there you can pas the date as parametter, as show in the example bellow. require or import are both support

  • for ES5 or ES2017

  • getTimePassed this method allow to get how much time passed until nom.
    const passedTime = require("passed-time");
    let date="2020-12-17 10:23";
    const pt= passedTime(date)
    console.log(pt.getTimePassed());    

this out put look like, it will be defferent according the time you will test

    1d
  • in case you would like to get more detail you can diffine the configuration detail to true
    const {PassedTime} = require("passed-time");
    // import {PassedTime} from "passed-time"; 
    let date="2020-12-17 10:23";
    const pt= new PassedTime(date)
    console.log(pt.getTimePassed({detail:true}));
    1d 7h 34m 50s

you can display allow available module as shown on the exemple bellow

    const {  PassedTime } = require('passed-time');

    let dat="2020-12-17 10:23";

    let past = new PassedTime(dat);

    let config={
        detail:true
    };

    let time = {
        timeLeft:past.getTimePassed(config),
        daysOfMonth:tp.getDayOfMonth(),
        thisWeekPeriod:tp.getThisWeek(),
        lastWeekPeriod:tp.getLastWeek(),
        thisTrimester:tp.getTriSemester()
    };
    console.log(time);

checkout ou the response will looks like

    {
        timeLeft: '1d 7h 37m 28s',
        daysOfMonth: 31,
        thisWeekPeriod: { from: '2020-12-13', to: '2020-12-19' },
        lastWeekPeriod: { from: '2020-12-06', to: '2020-12-12' },
        thisTrimester: { from: '2020-09-17', to: '2020-12-17' }
    }

in case you need to get the differnet between two date

    let date={
        firstDate:"2020-12-17 10:23",
        secondDate:"2020-12-17 10:20"
    };
    let tp = new PassedTime(dat);
    console.log(tp.getTimePassed(config))

this is the output

    3m 0s

Package Sidebar

Install

npm i passed-time

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

27.6 kB

Total Files

18

Last publish

Collaborators

  • ibmussa