A vue component that provides datepicker for persian developers

Overview

vue persian datepicker

Build Status Dependency Status Coverage Status

This is a Jalali date picker component for Vue.

این برنامه یک کامپوننت انتخاب تاریخ جلالی می باشد.

Demo

You can see a demo and several examples in this page: Demo & examples

Universal Module Definition(UMD)

In order to use datepicker without node package manager include these scripts and style sheet ( I recommend using unpkg ):

<link href="https://unpkg.com/vue2-persian-datepicker/dist/vue2-persian-datepicker.css" rel="stylesheet"></script>
<script type=text/javascript src="https://unpkg.com/vue"></script>
<script type=text/javascript src="https://unpkg.com/vue2-persian-datepicker/dist/vue2-persian-datepicker.js"></script>

Then register the component :

Vue.component('pdatepicker', PDatePicker.PDatePicker);

For a complete example you can see this jsFiddle .

NPM

$ npm install vue2-persian-datepicker

Then register the component:

import Vue from 'vue'
import PDatePicker from 'vue2-persian-datepicker'
Vue.component('pdatepicker', PDatePicker)

Usage

After registering the component you can use it in your markup:

<pdatepicker></pdatepicker>

Basic usage

In most cases you use pdatepicker to provide a persian date picker for your users to pick a date from. So, you need a way to get selected date. You can easily achieve this by syncing a variable.

This is pretty much what you have to do in order to get selected date or display a date to a user:

<pdatepicker v-model="date"></pdatepicker>
export default{
    data(){
        return {
            date : '1396/6/8'
        };
    }
}

Properties

Property Type Default Description
placeholder String یک تاریخ را انتخاب کنید Place holder of input
header-color Color 'white' Header text color
header-background-color Color '#137e95' Header background color
hover-day-back-color Color '#137e95' Background color when mouse hovers an element
chosen-day-back-color Color '#137e95' Background color for chosen day
dialog-color 'black' Color Dialog text color
dialog-background-color Color '#fafafa' Dialog background color
minimum-year Number 1300 Minimum selectable year for user
maximum-year Number 1350 Maximum selectable year for user
name String '' Name element for normal http form submit
required Boolean false value of HTML required attribute
id String '' value of input's id attribute
input-class String '' css class for input element
dialog class String '' css class for dialog element
wrapper-class String '' css class wrapper element of component
input-disabled Boolean true for responsive reasons input is disabled by default but you can enable it if you need to.
initial-view String 'day' Initial view of component (year or month or day)
inline-mode Boolean false inline mode
format-date String 'yyyy/MM/dd' formats output date. order of date element should not change
open-transition-animation String 'slide-fade' you can specify a transition for opening and closing dialog.
persianDigits Boolean true whether to use persian or english digits
availableDates Boolean false If you want limit user to certain range of dates
availableDateStart String 1300/01/01 In case of setting availableDates to true, use this to set start date
availableDateEnd String 1450/12/29 In case of setting availableDates to true, use this to set end date
disableDatesBeforeToday Boolean false This will disable all dates before today
modal-mode Boolean false This will make dialog modal.
modal-open-transition-animation String 'scale-fade' you can specify a transition for opening and closing dialog in modal mode.

Events

event Parameters description
opened Date String The picker's dialog is opened
closed Date String The picker's dialog is closed
monthChanged Date String Month page has changed
yearChanged Date String Year page has changed
selected Date Object A date has been selected
input Date String Input changed

Get selected date

Using v-model you can sync a value to selected date. Or, you can listen to selected event and get selected date.

Date formatting

There are several ways you can print selected date on user input. Keep in mind that you have to keep order of date (year/month/date)

token desc example
d day 3
dd day with 0 prefixed day 03
M month number 4
MM month with 0 prefix day 04
MMM month name فروردین
yy two digits year 96
yyyy four digits year 1396
Comments
  • Date formatting not work properly

    Date formatting not work properly

    hi and thanks for your greate library. I change the Date formatting, in input i see the Date formatting that i used, but the value is not the same , and is in 'yyyy/M/d' format. for example i use this: but "this.followdate" value is in 'yyyy/M/d' format for more information , i select date and it shows : ۱۳۹۷/۰۴/۰۲ but the input value is: ۱۳۹۷/۴/۲ please help me, i need to solve this problem.

    bug next release 
    opened by MINASHIJ 5
  • month is gone after jumping to the next year

    month is gone after jumping to the next year

    hi, I did implement the structure of your component just like the doc, when I just go from 'اسفند' of 139x to the next year, there is no change in the year (remains on 139x) and the month title is gone! with no error is thrown check the image I sent thank you very much for your component
    2017-12-09

    opened by beigiz 4
  • Show current date in textbox

    Show current date in textbox

    Hi, Is it possible to show current date in text box initially? Is it possible to use this as date converter to/from Jalali to Georgian? Thanks in advance.

    opened by aebrs 3
  • Wrong dates

    Wrong dates

    The datepicker provides wrong dates. For instance "Esfand" is a 29-day month this year. But your datepicker shows 30 days which is wrong. It also shows the same for the year 1394.

    bug 
    opened by farzadso 3
  • Error with vue

    Error with vue

    Hi, I write this code : <pdatepicker v-model='date' inline-mode=true ></pdatepicker>

    When running this code, the following error happened:

    [Vue warn]: Invalid prop: type check failed for prop "inlineMode". Expected Boolean, got String.

    How can I solve it?!

    opened by mariajhn 3
  • How to select year !? How to type date !?

    How to select year !? How to type date !?

    how can I select year !? and how can I type date in selected format directly !?

    //=========== update :

    thanks , I developing a website for a company and they have to use large screen , mouse and keyboard for their display and input devices , so having formated input will ease their users ....

    and what about selecting year !?

    I want to use this DatePicker for BirthDate and right now , I have to click more than 40 times to set year of customer's birth date to something like 1356 and this is nightmare !!!

    I just decide to use Vue for this project in day before yesterday and I'm relativity new in this field ,, but If I had time to work more with Vue and find any solution for these problems , I would share it with you ...

    thanks for your effort ...

    opened by RezaPouya 3
  • Setting availableDateEnd Shows year 1300 in openDialog

    Setting availableDateEnd Shows year 1300 in openDialog

    If I set availableDates="true" when we open the dialog to chnage the map by default it shows first month of year 1300.

    <pdatepicker :modal-mode="true" :placeholder="someDay" :availableDates="true" :availableDateEnd="someEndDay" @selected="someEvent"/>
    

    Screenshot from 2020-01-07 15-29-58

    opened by rahimramezanian 1
  • how to add a class to datepicker

    how to add a class to datepicker

    hi , I need to add some bootstrap class to this date picker . I tried this <pdatepicker name="BirthDateStr" id="BirthDateStr" class="form-control" placeholder="تاریخ تولد" type="text" v-model='birthdate'></pdatepicker>

    but the rendered result is this :

    <div data-v-157d4eff="" class="pdatepicker form-control" type="text"><input data-v-157d4eff="" id="BirthDateStr" name="BirthDateStr" placeholder="تاریخ تولد" readonly="readonly" class="" type="text">// code here </div> <!---->

    it seems that date picker component create input inside a div and add my class attribute to div while I need it to be added to input tag not div tag ...

    Is there a way around it !?

    opened by RezaPouya 1
  • Open closest allowed date to today if availableDates is set

    Open closest allowed date to today if availableDates is set

    hi, in the demo for availableDates, the user is presented with the current month (dey) which has no available dates. I find this to be counter-intuitive.

    instead, the date picker should open azar which is the last month with any available dates in it, or the first month if the range is in the future.

    bug 
    opened by zumoshi 1
  • خطای وابستگی

    خطای وابستگی

    Module build failed: ReferenceError: Unknown plugin "transform-runtime" specified in "/Projects/xxx/node_modules/vue2-persian-datepicker/.babelrc" at 0, attempted to resolve relative to "/Projects/xxx/node_modules/vue2-persian-datepicker"

    bug 
    opened by AmirTheH 1
  • خطا در اجرای پروژه

    خطا در اجرای پروژه

    در اجرای برنامه با خطای زیر مواجه شدم

    $ npm run dev
    
    > [email protected] dev F:\Download\vue\vue2-persian-datepicker
    > node build/dev-server.js
    
    > Starting dev server...
    
    
     ERROR  Failed to compile with 1 errors                                                                         15:51:47
    
    This dependency was not found:
    
    * !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../node_modules/vue-loader/lib/style-compiler/index?{"vue":true,"id":"data-v-3ee29d11","scoped":true,"hasInlineConfig":false}!sass-loader?{"sourceMap":false}!../../node_modules/vue-loader/lib/selector?type=styles&index=0!./PDatePicker.vue in ./src/components/PDatePicker.vue
    
    To install it, you can run: npm install --save !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../node_modules/vue-loader/lib/style-compiler/index?{"vue":true,"id":"data-v-3ee29d11","scoped":true,"hasInlineConfig":false}!sass-loader?{"sourceMap":false}!../../node_modules/vue-loader/lib/selector?type=styles&index=0!./PDatePicker.vue
    > Listening at http://localhost:8080
    
    opened by tandis 1
  • پیشنهاد توسعه

    پیشنهاد توسعه

    سلام پیشنهادی دارم برای افزودن قابلیت نمایش مناسبت به برنامه ای که توسعه دادید

    الان که همه ی سیستم ها به اینترنت متصل هستند پیشنهاد میکنم ارتباط با ای پی آي های تقویم رو هم در این سورس خوب پیاده سازی کنید خودم از این سرویس زیاد استفاده میکنم

    وب سرویس تقویم فارسی

    اطلاعات خوبی ارائه میده مثل وقایع و مناسبت های هر روز و دریافت رویداد در حالت شمسی و قمری و میلادی
    opened by mehrdadashtari 0
  • Not showing initialValue

    Not showing initialValue

    Hey there! I think my issue may be related to this: https://github.com/dyonir/vue2-persian-datepicker/issues/25

    But, as I wasn't sure, I created this new separate issue

    If my model to pdatepicker component has a value, it doesn't show up in input, I had to add this, to temporary fix this.

    image

    opened by aghArdeshir 0
  • availableDateStart Dosen't get updated dynamically

    availableDateStart Dosen't get updated dynamically

    salam va mersi az component khubetun value availableDateStart bad az entekhab yek variable be soorat dynamic avaz mishe ama in limit rooye date picker anjam nemishe rahi baraye re-initial kardane component ba in meghdare jadid hast ? mamnoon

    opened by beigiz 0
  • v-model won't set the date inside the date picker input

    v-model won't set the date inside the date picker input

    I tried to set the data model for date-picker but it's not working and I have to show the preset date somewhere else around the input to show to user.

    opened by hesan-aminiloo 2
Releases(2.0.0)
  • 2.0.0(Feb 1, 2018)

    This will add year list for users to select from also contains fixes for several bugs and improvements. Now dialog will close on click away

    Source code(tar.gz)
    Source code(zip)
  • 1.9.9(Feb 1, 2018)

    This will add year list for users to select from also contains fixes for several bugs and improvements. Now dialog will close on click away

    Source code(tar.gz)
    Source code(zip)
Owner
Dyon Software Development Group
Dyon Software Development Group
This datepicker is a fully customisable Vue(v2.1.6) version of the material-ui datepicker

vue-material-datepicker This datepicker is a fully customisable Vue(v2.1.6) version of the material-ui datepicker that fit all your projects. See belo

Bastien Granger 54 Dec 13, 2021
A VueJs datepicker with a similar look and functionality as the popular AirBnb datepicker.

vue-airbnb-style-datepicker This is a VueJs version of the popular AirBnb datepicker. Supports range selection, disabling of dates, custom configurati

Mikael Edebro 498 Dec 4, 2022
Vue Nuxt Scroll Datepicker - Fast, powerful and easy to use component datetime picker for Nuxt Vue

Vue Nuxt Scroll Datepicker - Cashbac In this article, we’ll look at how date and time picker and a virtual scroll. Fast, powerful and easy to use comp

mohammad ichlas 2 Apr 25, 2022
[Deprecated] calendar and datepicker component with material design for Vue.js

vue-datepicker calendar and datepicker component with material design for Vue.js Demo The demo page is HERE. Requirements Vue.js ^1.0.0 & ^2.0.0 momen

Awe 706 Nov 21, 2022
A simple Vue.js datepicker component. Supports disabling of dates, inline mode, translations

Datepicker A datepicker Vue component. Compatible with Vue 2.x Demo Install Usage Date Formatting Props Events Disabled dates Highlighted dates Transl

Charlie Kassel 2.6k Jan 3, 2023
datepicker component for Vue 2.x

vue-date-picker datepicker component for Vue 2.x Screenshot Instllation $ npm install vue-date-picker --save Usage <template> <div class="demo">

8788 101 Nov 21, 2022
Litepie Datepicker is a date range picker component for Vue.js and Tailwind CSS, dependent to day.js.

Litepie Datepicker is a date range picker component for Vue.js and Tailwind CSS, dependent to day.js. Documentation For full documentation, visit lite

Ken 346 Jan 3, 2023
awesome, zero dependency, performant Vue datepicker component

awesome, zero dependency, performant Vue datepicker component

mohammad S. 36 Oct 31, 2022
Vue Datepicker Component

Datepicker Component For Vue

Hatice Edis 405 Jan 5, 2023
Datepicker component for Vue 3

The most complete date picker solution for Vue 3

null 158 Dec 27, 2022
Datepicker component for vue.js built with Tailwind CSS, and the day.js date library.

Datepicker component for vue.js build with Tailwind CSS & dayjs date library

Ken 188 Nov 11, 2022
Simple datepicker component for Vue 3

Simple datepicker component for Vue 3

Ilya Borovitinov 111 Dec 17, 2022
Vue draggable datepicker component

DraggableCal A datepicker Vue component. Compatible with Vue 2.x Demo Install Usage Available Languages Dev & Build Licence Thanks Demo To view a demo

null 3 Feb 5, 2022
A lightweight and easy to use Vue.js datepicker component

A lightweight and easy to use Vue.js datepicker component (created for Vue 2.x)

Matt Areddia 0 Feb 5, 2019
A simple Vue.js datepicker component. Supports disabling of dates, inline mode, translations

Datepicker 2 A datepicker Vue component. Compatible with Vue 2.x Demo Install Upgrade to 2.x+ Usage Date Formatting Props Events Disabled dates Highli

hokify 15 Jul 28, 2022
A Beautiful Datepicker Component For Vue2

vue-datepicker-local A Beautiful Datepicker Component For Vue2 Lightweight (less than 5kb minified and gzipped) Only dependencies Vue Beautiful! Demo

飞越 300 Dec 13, 2022
A simple datepicker component for vue3.0

A simple datepicker component for vue3.0

Lin Masahiro 34 Dec 14, 2022
Jalaali calendar and datepicker for vue.js 2

vue-jalaali-datepicker Jalaali calendar and datepicker for vue.js 2 Demo Requirements Vue.js ^2.0.0 moment-jalaali ^0.6.0 Installation npm $ npm insta

Peyman 13 Nov 24, 2022
vue 3 datepicker. supports disabling, highlighting of dates and programmatic access of date.

Vue 3 Datepicker A datepicker Vue component. Compatible with Vue 3 Only Demo Install Usage Date Formatting Props Events Disabled dates Highlighted dat

shubhadip 38 Dec 15, 2022