npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mesa-libs/dates

v1.0.5

Published

This package is going to use dayjs library to standardly the way backends work with dates

Downloads

3

Readme

Date Manager

Mesa Mobile Thinking

Description

This library have to be used in backend projects to work with dates. It is going to standardize the way all projects work with dates. This libbrary uses dayjs to work with dates.

How it works?

This library exports only one class with static methods, so the only thing you have to do is import the class and call its methods.

Getting current date

This method returns the current date as an iso string

import { DateManager } from '@mesa-libs/dates';

const currentate = DateManager.now();

console.log(currentate); // expected output: string with current date in iso 8601 format. Eg: 2019-01-25T02:00:00.000Z

Getting a formatted date

This method returns the sent date with the format sent. If any format were sent the default format is going to be 'YYYY-MM-DD'.

import { DateManager } from '@mesa-libs/dates';

const date = DateManager.formatDate('2023-12-21 23:34:01', 'DD-MM-YYYY HH:mm:ss');

console.log(date); // expected output: 21-12-2023 23:34:01


const date = DateManager.formatDate('2023-12-21', 'DD-MM-YYYY');

console.log(date); // expected output: 21-12-2023


const date = DateManager.formatDate('2023-12-21', 'DD-MM-YY');

console.log(date); // expected output: 21-12-23


const date = DateManager.formatDate('2023-12-21');

console.log(date); // expected output: 2023-12-21

cheking if the sent date is expired

This method returns TRUE when a date is expired and false if the date is not expired.

import { DateManager } from '@mesa-libs/dates';

// considering current date as 2024-01-01

// testing current date
const expired = DateManager.isExpired('2024-01-01');

console.log(expired); // expected output: FALSE


// testing a past date
const expired = DateManager.isExpired('2023-12-21');

console.log(expired); // expected output: FALSE


// testing a future date
const expired = DateManager.isExpired('2024-12-21');

console.log(expired); // expected output: TRUE