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

sydate

v0.0.4

Published

原生 Date 对象扩展

Downloads

2

Readme

sydate npm

sydate 原生 Date 对象扩展,node 模块

引入、使用 sydate

Demo

const SyDate = require('sydate')

console.log(new SyDate().year)  // 2020
console.log(new SyDate().month) // 8
console.log(new SyDate().getNextDate.strftime()) // 2020-08-06 18:53:57
console.log(new SyDate().getDateTime(-100).strftime('%Y/%M/%d %H:%m:%s')) // 2020/04/27 18:55:05

方法

| 方法名 | 说明 | 参数 | 参数类型 | 默认值 | 版本 | | ---- | ---- | ---- | ---- | ---- | ---- | | getDateTime | 传入正负数计算多少天前/后的此时此刻 | day | Number | 1 | - | | strftime | 传入 new Date() 格式化时间 | dateFormat | String | '%Y-%M-%d %H:%m:%s' | - |

strftime 参数说明

请注意大小写,% 可去除

| 格式 | 含义 | 备注 | 举例 | | ---- | ---- | ---- | ---- | | %Y | 四位数年份 | - | 2019 | | %y | 两位数年份 | - | 19 | | %M | 月份 | - | 01 | | %_M | 月份 | 不补0 | 1 | | %d | 日期 | - | 02 | | %_d | 日期 | 不补0 | 2 | | %H | 24小时制 | - | 03 | | %_H | 24小时制 | 不补0 | 3 | | %h | 12小时制 | - | 16点,04 | | %_h | 12小时制 | 不补0 | 16点,4 | | %m | 分钟 | - | 05 | | %_m | 分钟 | 不补0 | 5 | | %s | 秒 | - | 06 | | %_s | 秒 | 不补0 | 6 |

属性

| 属性名 | 说明 | 举例 | 备注 | | ---- | ---- | ---- | ---- | | year | 年份 | 2020 | - | | month | 月份 | 8 | - | | day | 日期 | 5 | - | | isLeapYear | 是否闰年 | true/false | - | | weekDay | 一周的第几天,从0开始,周日是每周的第一天,0 | 3 | - | | weekDayName | 英文周几 | Wednesday | - | | weekDayNameCn | 中文周几 | 星期三 | - | | weekDayAbbr | 英文周几缩写 | Wed. | - | | weekDayAbbrCn | 中文周几缩写 | 三 | - | | monthName | 英文几月 | August | - | | monthAbbr | 英文几月缩写 | Aug. | - | | monthNameCn | 中文几月 | 八月 | - | | yday | 一年中第几天 | 218 | - | | hour | 几点了 - 时钟,24小时制 | 18 | - | | hour12 | 几点了 - 时钟,12小时制 | 6 | - | | min | 几点了 - 分钟 | 6 | - | | sec | 几点了 - 秒 | 25 | - | | msec | 几点了 - 毫秒 | 949 | - | | atStartOfDate | 日初,当天的 00:00:00 | - | - | | atEndOfDate | 日末,当天的 23:59:59 | - | - | | atStartOfWeek | 周初那天的此时此刻 | - | - | | atEndOfWeek | 周末那天的此时此刻 | - | - | | atStartOfMonth | 月初那天的 00:00:00 | - | - | | atEndOfMonth | 月末那天的 00:00:00 | - | - | | atStartOfYear | 年初那天的 00:00:00 | - | - | | atEndOfYear | 年末那天的 00:00:00 | - | - | | getPreviousDate | 前一天的此时此刻 | - | - | | getNextDate | 后一天的此时此刻 | - | - |