Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

vue-datetime-custom

kristof9415MIT1.0.7

FORK of https://github.com/mariomka/vue-datetime - Mobile friendly datetime picker for Vue. Supports date, datetime and time modes, i18n and disabling dates.

datetime, datetime-picker, picker, date, vue

readme

vue-datetime

Software License Latest Version on NPM npm Vue 2.x Build Coverage

FORK OF https://github.com/mariomka/vue-datetime - Mobile friendly datetime picker for Vue. Supports date, datetime and time modes, i18n and disabling dates.

NOTICE: This README is related to next version (1.0.x) of vue-datetime-custom. For the old release 0.x, see here.

Installation

You have to intall Font-awesome for VueJs

Bundler (Webpack, Rollup...)

yarn add luxon npm i vue-datetime-custom weekstart

Or

npm install --save luxon npm i vue-datetime-custom weekstart

weekstart is optional, is used to get the first day of the week.

Register

import Vue from 'vue'
import Datetime from 'vue-datetime-custom'
// You need a specific loader for CSS files
import 'vue-datetime/dist/vue-datetime-custom.css'

Vue.use(Datetime)

Register manually

Global
import { Datetime } from 'vue-datetime-custom';

Vue.component('datetime', Datetime);
Local
import { Datetime } from 'vue-datetime';

Vue.extend({
  template: '...',
  components: {
    datetime: Datetime
  }
});

Browser

Download vue, luxon, weekstart and vue-datetime or use a CDN like unpkg.

<link rel="stylesheet" href="vue-datetime-custom.css"></link>
<script src="vue.js"></script>
<script src="luxon.js"></script>
<script src="weekstart.js"></script>
<script src="vue-datetime.js"></script>

weekstart is optional, is used to get the first day of the week.

Usage

Minimal

<datetime v-model="date"></datetime>

Custom

You can customize the component output using named slots and component props.

<datetime v-model="date" input-id="startDate">
  <label for="startDate" slot="before">Field Label</label>
  <span class="description" slot="after">The field description</span>
</datetime>

Setup

Parameters

Parameter Type Default Description
v-model (required) ISO 8601 String - Datetime.
type String date Picker type: date, datetime or time.
input-id String '' Id for the input.
input-class String '' Class for the input.
hidden-name String null Name for hidden input with raw value. See #51.
value-zone String UTC Time zone for the value.
zone String local Time zone for the picker.
format Object or String DateTime.DATE_MED, DateTime.DATETIME_MED or DateTime.TIME_24_SIMPLE Input date format. Luxon presets or tokens.
phrases Object {ok: 'Ok', cancel: 'Cancel'} Phrases.
use12-hour Boolean false Display 12 hour (AM/PM) mode
hour-step Number 1 Hour step.
minute-step Number 1 Minute step.
min-datetime ISO 8601 String null Minimum datetime.
max-datetime ISO 8601 String null Maximum datetime.
auto Boolean false Auto continue/close on select.
week-start Number auto from locale if weekstart is available or 1 First day of the week. 1 is Monday and 7 is Sunday.

Input inherits all props not defined above but style and class will be inherited by root element.

The component is based on Luxon, check out documentation to set time zones and format.

Internationalization

Date internationalization depends on luxon. Set the default locale.

import { Settings } from 'luxon'

Settings.defaultLocale = 'es'

Events

Component emits the input event to work with v-model. More info.

close event is emitted when the popup closes.

Also, input text inherits all component events.

Theming

Theming is supported by overwriting CSS classes.

Development

Launch lint and tests

yarn test

Launch visual tests

yarn dev

Build

Bundle the js and css to the dist folder:

yarn build

License

The MIT License

changelog

Changelog

All notable changes to this project will be documented in this file.

Generated by auto-changelog.

v1.0.0-beta.8

14 October 2018

v1.0.0-beta.7

14 October 2018

v1.0.0-beta.6

9 July 2018

v1.0.0-beta.5

9 July 2018

v1.0.0-beta.4

8 July 2018

  • apply default rounded time when using minute step - resolves #56 #56
  • Generate hidden input with raw value when name is passed 32f8744
  • macro tokens are supported. 5db1a70
  • Add test for macro tokens format d995e02
  • Fix value formatting with `type=date` and specified time zone 522b19d
  • Rename `name` attribute by `hidden-name` f06fc41
  • Update readme 4bcbeef
  • Fix time zone for macro tokens format f868eb6
  • fix format describe c2a3456
  • fix format describe 5f44166
  • Macro tokens are supported. 74deb7d

v1.0.0-beta.3

3 February 2018

  • Add 12/24 hour format option to the time picker. #39
  • Update issue template 4c5de6d
  • Fix demo example code 2a5944f

v1.0.0-beta.2

23 January 2018

  • Add `week-start` parameter 6cb9279
  • Update demo 057f87a
  • Fix issue with value time zone 035d4da
  • Refactoring calendar new date d82d09c
  • Rename `date` by `datetime` in `Datetime.vue` 296f2c0
  • Refactoring 7d40f6f
  • Rename and improve `clearTime` util ccd80f5
  • Fix demo webpack 579096d
  • Add `luxon` in rollup globals config 46551bf
  • Add demo link to readme 44c667f
  • Remove auto-changelog limit f972692

v1.0.0-beta.1

19 January 2018

  • Cancel popup on key down ESC or TAB 47c8fca
  • Close popup on press ESC key 072063f
  • Continue or confirm popup on key down ENTER ff281ca
  • Fix auto on select time 69edaaa
  • On open popup blur input 5155ac7

v1.0.0-alpha.8

18 January 2018

  • Value will be an empty string instead of null when the date is empty or invalid because value type is a string. 3fa3463
  • Update luxon peer dependency version 2dd13b2

v1.0.0-alpha.7

18 January 2018

  • Watch value changes d58b910
  • Update readme and issue template 8adff3d
  • Ignore all vue devtools globals in mocha 7daee98
  • Update issue template b525ff6

v1.0.0-alpha.6

16 January 2018

v1.0.0-alpha.5

15 January 2018

v1.0.0-alpha.4

15 January 2018

  • Reformat code 6391d30
  • Add minimum and maximum datetimes. 5467eec
  • Clear time when type is date 317d0b4
  • Add notice and todo to readme 6a8855b
  • Refactor utils 45a82a3
  • Update readme parameters section 4461ab5
  • Add `VUE_DEVTOOLS_TOAST` to accepted global variables names in mocha. 1b40d2f

v1.0.0-alpha.3

25 December 2017

v1.0.0-alpha.2

25 December 2017

  • Add year picker c7766c8
  • Update `phrases` test c056826
  • Pass time steps from date picker to time picker through the popup. fd2d338
  • Fix tests 539a5cf
  • Refactor flow 7b19f2f
  • Rename `i18n` prop by `phrases` and add it to `Datetime` component 46e10ff
  • Add `auto-changelog` package to auto generate changelog on every version db2b5ea
  • Update readme d882209
  • Remove `wrapper-class` and `input-class` props. Use `class` attribute instead. 5017b63
  • Refactor how years, hours and minutes are generated. e3e5429
  • Update readme 5d60ed3
  • Update readme 63c1c43
  • Fix transition z-index issue 9ac6aa9
  • Remove unused prop c709478
  • Remove duplicated year from header f2ba651
  • Update readme d04236a

v1.0.0-alpha.1

20 December 2017