Code Monkey home page Code Monkey logo

simpler-date-format's Introduction

SimplerDateFormat(pattern: string,[week: Array])

This package likes java's SimpeDateFormat. But it is simpler 😜!

1. api

format(date: Date);  // format time you want
zone(number);           // setZoneTime and format

2. Usage

english

Capital letters for date and lowercase letters for time, letters are random, Using space separation, The order in which you enter is the order in which you output. Use special symbols(except ~) to represent what day of the week you output. add ~ before sentence to reverse output;

chinese

日期用大写字母,时间用小写字母,字母是随机的,

使用空格分隔,输入的顺序是输出的顺序。使用特殊符号(除~)表示一周中输出的日期。

在句子前加~可反转输出;

const SimplerDateFormat = require('simpler-date-format');

const weekday = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday' ,'Sunday'];

var sd = new SimplerDateFormat('Y/M/D h:m:d');
sd.format(new Date());              //2019/04/23 22:36:44

var sd = new SimplerDateFormat('Y$M$D h:m:d @');
sd.format(new Date());              //2019$04$23 22:36:44 2

var sd = new SimplerDateFormat('h:m:d Y/M/D');
sd.format(new Date());              //22:36:44 2019/04/23

var sd = new SimplerDateFormat('@ h:m:d ~Y/M/D', week);
sd.format(new Date());              // Tuesday 22:36:44 04/23/2019

var sd = new SimplerDateFormat('h:m:d ~Y/M/D', week);
sd.zone(8);              //22:36:44 04/23/2019 Tuesday Beijing time

3. many functions are not added, coming soon

if you like, please star on github❤

simpler-date-format's People

Stargazers

Felice Stracke avatar ChiXuChao avatar  avatar

Forkers

han9423

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.