Coder Social home page Coder Social logo

33mestre / better-dateinput-polyfill Goto Github PK

View Code? Open in Web Editor NEW

This project forked from luiz/better-dateinput-polyfill

0.0 3.0 0.0 392 KB

input[type=date] polyfill for better-dom

Home Page: http://chemerisuk.github.io/better-dateinput-polyfill/

License: MIT License

JavaScript 86.40% HTML 4.41% CSS 9.19%

better-dateinput-polyfill's Introduction

better-dateinput-polyfill
Build Status Coverage Status Bower version

input[type=date] polyfill for better-dom

Why another date picker? The problem is that most of existing solutions do not follow standards regarding to value property format, that should have โ€œa valid full-date as defined in [RFC 3339]โ€. In other words representation of date can vary, but the string value should have yyyy-MM-dd format. It helps to work with such values consistently regarding on the current language.

VIEW DEMO

Features

  • normalizes input[type=date] presentation for desktop browsers
  • skips mobile browsers, they have good UI widget and correct value format
  • submitted value always has yyyy-MM-dd [RFC 3339] format
  • live extension - works for current and future content
  • placeholder attribute works as expected in browsers that support it
  • fully customizable date picker, including date format displayed to the user
  • keyboard and accessibility support
  • full i18n support (if your language is missed - just translate strings from i18n folder and include a new file in your project)
  • US variant for days of week is supported (use <html lang="en-US">)

Installation

The simplest way is to use bower:

$ bower install better-dateinput-polyfill

This will clone the latest version of the better-dateinput-polyfill with dependencies into the bower_components directory at the root of your project.

Then append the following script on your page:

<script src="bower_components/better-dom/dist/better-dom.js"></script>
<script src="bower_components/better-i18n-plugin/dist/better-i18n-plugin.js"></script>
<script src="bower_components/better-dateinput-polyfill/dist/better-dateinput-polyfill.js"></script>

Custom formats

Displayed date can be formatted using a data-format attribute on the <input type="date">. For example:

<input type="date" data-format="EE, MMMM dd'th' yyyy">

This will display the selected date like "Monday, December 8th 2014" on the input.

If data-format is not specified, date is formatted using the pattern "E, dd MMM yyyy".

Possible parameters for the format are:

Letter Date Component Presentation Examples
y Year Year 2002; 02; 2
M Month in year Month July; Jul; 07; 7
w Week in year Number 07; 7
W Week in month Number 2
D Day in year Number 009; 9
d Day in month Number 08; 8
F Day of week in month (1st, 2nd, 3rd Tuesday) Number 2
E Day name in week Text Tuesday; Tu.
u Day number of week (1 = Monday, ..., 7 = Sunday) Number 1

Number of letters in the parameter name specifies form of the output value, for instance:

"M" yields "1"
"MM" yields "01"
"MMM" yields "Jan"
"MMMM" yields "January"

Browser support

Desktop

  • Chrome
  • Safari 6.0+
  • Firefox 16+
  • Opera 12.10+
  • Internet Explorer 8+ (see notes)

Mobile

  • iOS Safari 6+
  • Android 2.3+
  • Chrome for Android

better-dateinput-polyfill's People

Contributors

chemerisuk avatar guizmo avatar luiz avatar marcorivm avatar nunoarruda avatar

Watchers

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