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

@drumtj/datex

v1.0.12

Published

extension Date class

Downloads

9

Readme

Datex

npm version license

This library is Date Class Extension

Features

  • leap year check available
  • day of week check available
  • week countable
  • can be get date range and convert to array
  • can be get date offset

Installing

Using npm:

$ npm install @drumtj/datex

Using cdn:

<script src="https://unpkg.com/@drumtj/[email protected]/dist/datex.js"></script>

Using amd, commonjS Module

const Datex = require('@drumtj/datex');
import Datex from '@drumtj/datex';

Example

var dx = new Datex();
if(dx.isMonday()){
  console.log("welcome to the hell", dx.getMonthName(), dx.getDayName());
}

if(dx.isLeapYear()){
  console.log(dx.getFullYear(), "is leap year");
}

//week count in year
dx.getWeekCount();

//set date to later 3day
dx.setOffset(3);
//set time to zero
dx.timereset();

//return new Datex object to set date to later 3day
dx.getOffset(3);
//offset for week
dx.getOffsetWeek(1);
//offset for month
dx.getOffsetMonth(1);
//return first day in week
dx.getFirstDayOfWeek()
//return first day in month
dx.getFirstDayOfMonth()
//return last day in week
dx.getLastDayOfWeek()
//return last day in month
dx.getLastDayOfMonth()



//interface DateRange{
//  startDate: Date;
//  endDate: Date;
//  weeks?: DateRange[];
//  toTimeArray?: ()=>number[]|number[][];
//  toDateArray?: ()=>Date[]|Date[][];
//  toDateStringArray?: ()=>string[]|string[][];
//}

//return DateRange
dx.getWeekRange(1)
//with split to 'DateRange' each week
dx.getWeekRange(1, true)
dx.getMonthRange(1)
//with split to 'DateRange' each week
var dateRange = dx.getMonthRange(1, true)

console.log(dateRange.toDateArray());

//format
dx.format(); //2019-07-02
dx.format("DDD MMM DD YYYY hh:mm:ss"); // Tue Jul 02 2019 16:22:06
dx.format("DDDD MMMM DD YYYY hh:mm:ss"); // Tuesday July 02 2019 16:22:06
dx.format("YYYY년 M월 D일 (DDD)", "ko"); // 2019년 7월 2일 (화)
dx.format("YYYY년 MM월 DD일 (DDDD)", "ko"); // 2019년 07월 02일 (화요일)

examples (source)

License

MIT