Giter Club home page Giter Club logo

npm-date-prototype's Introduction

Date.prototype

v3.5.0 Jun 2012

Date.prototype provides JavaScript Date instance methods for parsing, formatting, and calculating dates. It uses a concise and configurable algorithm for interpreting format codes.

Features include:

  • Parses almost any format with ability to register custom format parsing.
  • Supports formatting codes for sprintf, php, and SQL with the ability to register custom formating.
  • Adds and subtracts years, months, days, hours, minutes or seconds.
  • Calculates differences between dates in a given unit.
  • Methods are available on all Date Objects.

Examples:

$D('2006-09-20').strftime('%m/%d/%Y'); // "09/20/2006"
$D('Sep 20 2006').add(3).strftime('%Y-%m-%d'); // "2006-09-23"
$D('09/20/2006').add(4, 'years').strftime('%Y-%m-%d'); // "2010-09-20"
$D('09/20/2006 20:15:00').add(4, 'hours').format('%Y-%m-%d %H:%M:%S'); // "2006-09-21 00:15:00"
$D('2006-09-20').format('m/d/Y'); // "09/20/2006"
$D('2006.09.28').diff('20 Sep, 2006', 'days'); // 8

See reference.html for demo and complete guide Unit Tests for demo and complete guide

ChangeLog

v3.5 Jun 2012

  • Add Date#equals, Date#isBefore, Date#isAfter
  • Add Date#schedule, Date#unschedule, Date#getSchedule
  • Add Date.Timer class
  • Centralize Date parse patterns

v3.4 Apr 2012

  • Fix UTC Offset handling
  • Recognize Chicago dates that are missing a comma
  • Recognize Conversational dates that have leading weekday name
  • Recognize 24-hour time that contains "GMT" and/or timezone name (e.g. native JS toString() format)
  • Recognize date expressions with millisecond units (e.g. "in 250 milliseconds", "250 milliseconds ago")
  • Recognize + and - date expressions (e.g. "+2 hours", "-3 years")
  • Recognize ASP JSON format (e.g. "/Date(1296824894700)/", "/Date(1296824894700-0700)/")
  • Use strict mode

v3.3 Dec 2011

  • Fixed documentation of Date#setUTCOffsetString
  • Ability to parse ISO-8601 dates containing timezone
  • Ability to parse RFC 2822 dates

v3.2 Jul 2011

  • Add ability to easily add and remove parse patterns
  • Update inline documentation to work with JSDoc
  • Update 12-hour regex to allow leading 0s

v3.1 Feb 2011

  • Update month addition/subtraction behavior: When new month has fewer days than original, go to last day of month instead of wrapping to next month.
  • Remove use of named function expressions

v3.0 Oct 2010

  • Initial push to Github
  • Unit tests using QUnit
  • Add support for PHP format codes L, t and e

v2.0 Sep 2008

  • Initial public release
  • Add unit tests
  • Create reference.html

v1.0 Dec 2005

  • Initial private release

Full Github History

npm-date-prototype's People

Contributors

ccwq 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.