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

xqtime

v0.1.0

Published

This is a js time-friendly plugin.

Downloads

23

Readme

xqtime

This is a js time-friendly plugin.

View Chinese documents

Install

Browser:

import cdn

<!-- Browser -->
<script src="https://xqgj.cc/xqcdn/libs/xqtime/xqtime.min.js"></script>
<!-- es module -->
<script type="module">
    import xqtime from '../lib/xqtime-esm.min.js';
</script>

Node:

npm install xqtime
const xqtime = require('xqtime');

Usage

Format description

  • Year month day format
const ymdDate = '2012-04-12 10:03:15';
// 2012-04-12 10:03:15
  • GMT format
const gmtDate = new Date();
// Fri Nov 12 2021 10:20:54 GMT+0800 (中国标准时间)

Use Cases

    1. General case
// call the friend method
const ymdDate = '2012-04-12 10:03:15';
const gmtDate = new Date();
let ymdResult = xqtime.friend(ymdDate);
let gmtResult = xqtime.friend(gmtDate);
console.log('ymd result:', ymdResult);
console.log('gmt result:', gmtResult);
// ymd result: 9 years ago
// gmt result: just now


// Attachment time
let ymdAppendResult = xqtime.friend(ymdDate, true);
let gmtAppendResult = xqtime.friend(gmtDate, true);
console.log('ymd append:', ymdAppendResult); // ymd append: 9 years ago (2012-03-04)
console.log('gmt append:', gmtAppendResult); // gmt append: just now (11:19:52)
    1. All cases
// current time
const now = new Date();
console.log('now is:', now); // now is: 2021-11-12T03:16:18.318Z

// just
const just = new Date();
let justResult = xqtime.friend(just);
console.log('just is:', justResult); // just is: just

// minute
const min = '2021-11-12 11:05:11';
let minResult = xqtime.friend(min);
console.log('min is:', minResult); // min is: 12 minutes ago

// Time
const hour = '2021-11-12 05:05:11';
let hourResult = xqtime.friend(hour);
console.log('hour is:', hourResult); // hour is: 6 hours ago

// day
const day = '2021-11-08 11:05:11';
let dayResult = xqtime.friend(day);
console.log('day is:', dayResult); // day is: 4 days ago

// moon
const mon = '2021-05-12 11:05:11';
let monResult = xqtime.friend(mon);
console.log('mon is:', monResult); // mon is: 6 months ago

// year
const year = '2012-11-12 11:05:11';
let yearResult = xqtime.friend(year);
console.log('year is:', yearResult); // year is: 9 years ago

// century
const century = '1920-11-12 11:05:11';
let centuryResult = xqtime.friend(century);
console.log('min is:', centuryResult); // min is: 1st century ago

// Millennium
const millennium = '960-11-12 11:05:11';
let millenniumResult = xqtime.friend(millennium);
console.log('millennium is:', millenniumResult); // millennium is: 1 thousand years ago

View xqtime

Run this script to view the demonstration case: npm run test:node, npm run test:browser.

ask questions

submit your question

Author

@gitguanqi