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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@dangao/date-util-es

v0.1.0

Published

Date extension

Readme

date-util-es

Date extension

install

npm i @dangao/date-util-es --save
//or
yarn add @dangao/date-util-es

case

In entry file

import "@dangao/date-util-es";

simple usage

const date = new Date();
console.info(date.format()); // 2019-03-14 15:14:00.000

Full extension

interface Date {
    /**
     * **日期格式化函数,旨在快速将指定Date实例快速格式化为需要的格式**
     * ***
     * 示例代码:
     * ```
     * const date = new Date().format('yyyy-mm-dd hh:min:ss.ms')
     * console.log(date);// 2019-03-14 15:14:00.000
     * ```
     * ***
     * @param fmt 格式化模板 --默认为`yyyy-mm-dd hh:min:ss.ms`
     * >格式化可选参数有
     * >>- yyyy:年份
     * >>- mm:月份
     * >>- dd:天
     * >>- hh:时
     * >>- min:分
     * >>- ss:秒
     * >>- ms:毫秒
     * ***
     * @param complation 位数不足是是否补位`0`
     */
    format(fmt?: string, complation?: boolean): string;
    /**
     * 以当前日期为基础增加时间(`毫秒`)
     * @param time 增加的时间(可以是负数)
     */
    calcTime(time: number): Date;
    /**
     * 以当前日期为基础增加时间(`秒`)
     * @param second 增加的时间(可以是负数)
     */
    calcSecond(second: number): Date;
    /**
     * 以当前日期为基础增加时间(`分钟`)
     * @param minute 增加的时间(可以是负数)
     */
    calcMinute(minute: number): Date;
    /**
     * 以当前日期为基础增加时间(`小时`)
     * @param hours 增加的时间(可以是负数)
     */
    calcHours(hours: number): Date;
    /**
     * 以当前日期为基础增加时间(`天`)
     * @param days 增加的时间(可以是负数)
     */
    calcDate(days: number): Date;
    /**
     * 以当前日期为基础增加时间(`周`)
     * @param week 增加的时间(可以是负数)
     */
    calcWeek(week: number): Date;
    /**
     * 以当前日期为基础增加时间(`月`)
     * @param month 增加的时间(可以是负数)
     */
    calcMonth(month: number): Date;
    /**
     * 以当前日期为基础增加时间(`年`)
     * @param month 增加的时间(可以是负数)
     */
    calcYear(year: number): Date;
    /** 获取当月第一天 */
    getFirstDate(): Date;
    /** 获取当月最后一天 */
    getLastDate(): Date;
    /** 是否是无效日期 */
    isInvalidDate(): boolean;
    /** copy当前日期 */
    copy(): Date;
    /** 判断是否是同一天 */
    isSameDayFrom(compare_date: Date): boolean;
    /** 判断是否是同一月 */
    isSameMonthFrom(compare_month: Date): boolean;
    /** 判断是否是同一年 */
    isSameYearFrom(compare_year: Date): boolean;
    /** 设置当前时间为00:00:00 */
    formatTime(): Date;
  }