New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

count-age

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

count-age

This tool counts differences between dates

latest
npmnpm
Version
3.1.2
Version published
Weekly downloads
6
500%
Maintainers
1
Weekly downloads
 
Created
Source

Count Age

This tool counts differences between dates

Install

npm i count-age

Usage:

import { countAge } from "count-age";

const myAge = countAge('2000-01-01T09:30:00.000Z');

I/O expectations

INPUT

Function can be provided by one input date or two.

  • If this will be provided only first date, second will be defined as now and function will count difference between input date and now .
  • If this will be provided two dates, function will count difference between provided dates.

Input dates can be string for date creation, timestamp number, or instance of next object:

type DateProps = {
  years: number;
  months: number;
  days: number;
  hours?: number;
  minutes?: number;
  seconds?: number;
};

OUTPUT

This function anyway returns object with status and message.

enum STATUS {
  SUCCESS = 'SUCCESS',
  ERROR = 'ERROR',
}
// error messages
enum MESSAGE {
    invalid = 'Invalid Date',
    startBiggerEnd = 'Start date is bigger than end date',
}

// success message
type templeteSuccessMessage = '{{ count }} year(s), {{ count }} month(s), {{ count }} day(s), {{ count }} hour(s), {{ count }} minute(s), {{ count }} second(s) have passed between dates: {{ date-start }} - {{ date-end }}'

Success result object also contains field result:

type result = {
    difference: { 
        years: number;
        months: number;
        days: number;
        hours: number;
        minutes: number;
        seconds: number;
    };
    startDate: string;
    endDate: string;
}

Keywords

age

FAQs

Package last updated on 30 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts