Giter Site home page Giter Site logo

frmttime's Introduction

frmttime - format JavaScript date (high performance)

Textual representation of javascript date object according to given pattern (date formatting).

One more implementation of javascript date formatting, focused at high speed and performance.

Javascript challenge 1st place winner (50x faster).

Installation

frmttime can be downloaded and used as typical javascript library/module ( it supports AMD, CommonJs and plain browser module exports)

as Page Script

<script type="text/javascript" src="path_to_frmttime"></script>
var formattedDate = window.frmttime.format('%y/%m/%d');

as AMD module:

define('myModuleName', ['frmttime'], function( frmttime ){
    var formattedDate = frmttime.format('%y/%m/%d');
})

frmttime can be installed as npm package:

npm install frmttime

And used as CommonJS:

var frmttime = require('frmttime');
var formattedDate = frmttime.format('%y/%m/%d');

Methods

Usage Examples

Supported Specifiers

Seconds:
  • L: the milliseconds, padded to 3 digits
  • S: the second, padded to 2 digits (00-60)
  • s: the number of seconds since the Epoch, UTC
Minutes:
  • M: the minute, padded to 2 digits (00-59)
Hours:
  • H: the hour (24-hour clock), padded to 2 digits (00-23)
  • I: the hour (12-hour clock), padded to 2 digits (01-12)
  • k: the hour (24-hour clock), padded with a leading space for single digit values (0-23)
  • l: the hour (12-hour clock), padded with a leading space for single digit values (1-12)
  • P: "am" or "pm" in lowercase
  • p: "AM" or "PM"
Days:
  • A: full weekday name
  • a: abbreviated weekday name
  • d: day of the month, padded to 2 digits (01-31)
  • e: day of the month, padded with a leading space for single digit values (1-31)
  • j: day of the year, padded to 3 digits (001-366)
  • o: day of the month as an ordinal (without padding), e.g. 1st, 2nd, 3rd, 4th, ...
  • w: the weekday, Sunday as the first day of the week (0-6)
  • u: the weekday, Monday as the first day of the week (1-7)
Weeks:
  • U: week number of the year, Sunday as the first day of the week, padded to 2 digits (00-53)
  • W: week number of the year, Monday as the first day of the week, padded to 2 digits (00-53)
Months:
  • B: full month name
  • b: abbreviated month name
  • h: the same as %b (abbreviated month name)
  • m: the month, padded to 2 digits (01-12)
Years:
  • C: AD century (year / 100), padded to 2 digits
  • Y: the year with the century
  • y: the year without the century (00-99)
Other equivalents, timezones, etc:
  • D: equivalent to %m/%d/%y
  • F: equivalent to %Y-%m-%d
  • n: newline character
  • R: equivalent to %H:%M
  • r: equivalent to %I:%M:%S %p
  • T: equivalent to %H:%M:%S
  • t: tab character
  • v: equivalent to %e-%b-%Y
  • Z: the time zone name, replaced with an empty string if it is not found
  • z: the time zone offset from UTC, with a leading plus sign for UTC and zones east of UTC and a minus sign for those west of UTC, hours and minutes follow each padded to 2 digits and with no delimiter between them

License

Copyright © 2014 Sergey Shpak [email protected]

MIT license

frmttime's People

Contributors

sergey-shpak avatar

Watchers

James Cloos avatar  avatar

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.