A vue plugin to select jalali date and time

Overview

vue3-persian-datetime-picker

npm version

A vue plugin to select jalali date and time

See documentation and demo at vue-persian-datetime-picker.

If you are using vuejs 2, please refer to this repository.

Installation

browser

<script src="https://unpkg.com/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/moment"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/moment-jalaali.js"></script>
<script src="/dist/vue3-persian-datetime-picker.umd.min.js"></script>
<div id="app">
  <date-picker v-model="date"></date-picker>
</div>
<script>
  Vue.createApp({
    data: function() {
      return {
        date: '1400/01/01'
      }
    },
    components: {
      DatePicker: Vue3PersianDatetimePicker
    }
  }).mount('#app')
</script>

npm

npm install vue3-persian-datetime-picker --save

Configuration for moment to ignore loading locales:

// vue.config.js:
module.exports = {
  //..
  configureWebpack: {
    plugins: [new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)]
  },
  //...
}

Usage

// main.js

import { createApp } from 'vue'
import Vue3PersianDatetimePicker from 'vue3-persian-datetime-picker'
const app = createApp({})
app.component('DatePicker', Vue3PersianDatetimePicker)
app.mount('#app')

Or in component

<template>
  <date-picker v-model="date"></date-picker>
</template>
 
<script>
  import DatePicker from 'vue3-persian-datetime-picker'
  export default {
    data(){
      return {
        date: ''
      }
    },
    components: { DatePicker }
  }
</script>

You can also set default values:

// main.js

import Vue3PersianDatetimePicker from 'vue3-persian-datetime-picker'
const app = createApp({})
app.use(Vue3PersianDatetimePicker, {
  name: 'CustomDatePicker',
  props: {
    format: 'YYYY-MM-DD HH:mm',
    displayFormat: 'jYYYY-jMM-jDD',
    editable: false,
    inputClass: 'form-control my-custom-class-name',
    placeholder: 'Please select a date',
    altFormat: 'YYYY-MM-DD HH:mm',
    color: '#00acc1',
    autoSubmit: false,
    //...
    //... And whatever you want to set as default.
    //...
  }
})

Then use in component

<custom-date-picker v-model="date"></custom-date-picker>

Click to see full documentation and demo

Built With

  • Vue.js - The Progressive JavaScript Framework.
  • Moment.js - Parse, validate, manipulate, and display dates and times in JavaScript.
  • moment-jalaali - A Jalaali (Jalali, Persian, Khorshidi, Shamsi) calendar system plugin for moment.js.

License

This project is licensed under the MIT License

Change log

1.0.0 (2021-08-14)

  • Migrated to Vue3
Comments
  • using on nuxt

    using on nuxt

    <سلام ممنون از شما بابت این پروژه واقعا کارآمد ولی امکان استفاده از اون روی ناکست فراهم نیست و یه مشکل خیلی بزرگ رو برای ما بوجود آورده این موضوع خیلیل ممنون میشم کمک کنید

    opened by SaeedP11 5
  • App crashes when used in vite project

    App crashes when used in vite project

    environment :

    • vite: 2.5.12
    • vue: 3.2.12
    • typescript: 4.4.3
    • node: 16.9.1
    • package manager: pnpm 6.15.1

    what is happening:

    app crashes because:

    TypeError: moment.localeData is not a function
        at node_modules/.pnpm/[email protected]/node_modules/moment-jalaali/index.js (index.js:200)
        at __require2 (chunk-FPJRMZPJ.js?v=d3346f7d:14)
        at Object.b9b3 (vue3-persian-datetime-picker.common.js:582)
        at __webpack_require__ (vue3-persian-datetime-picker.common.js:21)
        at Module.fb15 (vue3-persian-datetime-picker.common.js:2021)
        at __webpack_require__ (vue3-persian-datetime-picker.common.js:21)
        at module2.exports.24fb (vue3-persian-datetime-picker.common.js:85)
        at node_modules/.pnpm/[email protected]/node_modules/vue3-persian-datetime-picker/dist/vue3-persian-datetime-picker.common.js (vue3-persian-datetime-picker.common.js:85)
        at __require2 (chunk-FPJRMZPJ.js?v=d3346f7d:14)
        at dep:vue3-persian-datetime-picker:1
    

    how to reproduce:

    try to use vue persian date picker in a vite and vue3 project no special edge case needed to trigger the errors

    side notes:

    vue persian date picker works fine in vue3 project made with vue-cli

    opened by RyanNorooz 2
  • Use min and max in vuejs 3

    Use min and max in vuejs 3

    Hi, How i can use min and max for datepicker in vuejs3? <date-picker v-model="newWork.deadline" type="datetime" format="YYYY-MM-DD HH:mm" display-format="jYYYY-jMM-jDD HH:mm" label="Deadline" min="1400/11/22"></date-picker> i write this but not working.

    opened by ninja71-mn 0
  • typescript definition

    typescript definition

    is there a typescript definition for the vue 3 version ? I'm getting "Could not find a declaration file for module 'vue3-persian-datetime-picker'" error on import.

    opened by DevIsShortForDevil 0
  • Problem working with unit testing

    Problem working with unit testing

    I use dusk in Laravel for testing. For example, in my vue file to get the date of birth:

    <div class="mb-2 col-md-4 col-sm-6">
        <label>تاریخ تولد</label>
        <div class="input-group">
            <input type="text" id="dateOfBirth" class="form-control form-control-sm" autocomplete="off">
            <date-picker v-model="user.date_of_birth" display-format="jYYYY/jMM/jDD"
                    convert-numbers custom-input="#dateOfBirth" format="YYYY-MM-DD"
                    :max="maxDateOfBirth" view="year"></date-picker>
        </div>
    </div>
    

    To test it, I have written:

    $browser
                ->press('#dateOfBirth')
                ->assertSourceHas('<div class="vpd-container">')
                ->press('.vpd-addon-list-item')
                ->pause(500)
                ->press('.vpd-addon-list-item')
                ->pause(500)
                ->press('.vpd-day')
                ->press('تایید')
                ->pause(500)
                ->assertDontSee('تایید')
                ;
    

    This code automatically clicks the first year in the list, then the first month and then the first day. In my opinion, instead of using the .vpd-addon-list-item class, each item should have a unique ID, While there is no. That is, if I want to test a specific date and time, it is not possible.

    opened by ali-salavati 0
  • pick date with simple mode

    pick date with simple mode

    Hey @talkhabi :)

    we have problem in picking date in simple mode

    in this mode if we pick a date, then want to change month, date picker cant handle the day and its gonna return the previous date ! in vue 2 we didn't have this issue.

    thanks for your great work <3

    opened by mahdi-toosi 0
  • باگ در انتخاب همزمان range و :max

    باگ در انتخاب همزمان range و :max

    باسلام، زمانی که دیت پیکر در حالت range هست و همزمان از attribute max استفاده میشه، تاریخ به کلی بهم میریزه.

    <date-picker format="YYYY/MM/DD" display-format="jYYYY/jMM/jDD" v-model="filters.date_range" locale="fa" max="1396/08/08" range />

    دیت پیکر در این حالت به این شکل در میاد: image

    opened by alih70442 1
  • حذف وابستگی‌های غیر ضروری

    حذف وابستگی‌های غیر ضروری

    سلام، شاید خیلی پرزحمت باشه ولی به نظرم برای نسخه vue3 بهتره Moment.js رو کنار بزاری و سعی کنی کامپوننت رو کاملاً مستقل کنی الان خود Moment.js هم تو سایتش اشاره میکنه که دیگه نیازی بهش نیست و به جاش بهتره از امکانات خود js استفاده بشه: https://momentjs.com/docs/#/-project-status/

    opened by a-shafaat 0
  • Reset Input Value

    Reset Input Value

    Hello @talkhabi Thanks for your great work, and please keep it up.

    How we can clear the selected date after modelValue has been changed? I have to add a reset button, for a filter area inputs that contain a datepicker, How can I achive this?

    So far, this is my setup look likes. Screenshot from 2021-12-18 15-00-12

    and input in my template. Screenshot from 2021-12-18 15-00-28

    but aftter reset event emitted, nothing happens. Any advice appreciated.

    opened by SaeedSoltoon 0
Owner
Mohamad Talkhabi
Mohamad Talkhabi
A vue plugin to select date and time

vue-date-time-picker-js A vue plugin to select date and time See documentation and demo at vue-date-time-picker-js Installation npm npm install vue-da

Mahdad Ghasemian 0 Mar 25, 2020
Mobile friendly datetime picker for Vue. Supports date, datetime and time modes, i18n and disabling dates.

Mobile friendly datetime picker for Vue. Supports date, datetime and time modes, i18n and disabling dates.

null 0 Feb 7, 2019
Lightweight and mobile friendly date time picker based on Vue.

Vue date pick Lightweight and mobile friendly date time picker based on Vue. Vue date pick emphasizes performance, elegant and usable UI on all screen

Damir Brekalo 247 Dec 8, 2022
A simple Vue.js date and time picker made with material design in mind

vue-material-date-time-picker A date and time picker Vue component. Compatible with Vue 2.x. Performed in material design. Demo Install Usage Props NB

Technorely Inc 8 Feb 2, 2022
A component for picking date & time

A Vue Component to pick a ranged datetime in calendar. Built alongside Vue 2.x . This datepicker utilize moment for translations.

Robin Boutros 0 Aug 4, 2021
VueJS component to select dates & time, including a range mode

VueCtkDateTimePicker A vue component for select dates (range mode available) & time This documentation is for v2.*. Find v1 documentation here Dark mo

Chronotruck 828 Dec 26, 2022
Vue Time Picker - A simple time picker for Vue with a Bootstrap style

Vue Time Picker - A simple time picker for Vue with a Bootstrap style

Justin Dowty 0 Feb 13, 2020
A dropdown time picker (hour|minute|second) for Vue 2.x, with flexible time format support

Vue2 Timepicker ?? Dead repo recharged ?? A dropdown time picker (hour|minute|second) for Vue 2.x, with flexible time format support. Demo You can see

Phoenix Wong 432 Dec 26, 2022
A dropdown time picker (hour|minute|second) for VueJs (1.x), with flexible time format support

A dropdown time picker (hour|minute|second) for VueJs (1.x), with flexible time format support

Phoenix Wong 28 Dec 16, 2020
Mobile friendly datetime picker for Vue. Supports date and datetime modes, i18n and more.

vue-datetime Mobile friendly datetime picker for Vue. Supports date, datetime and time modes, i18n and more. Demo Go to demo. Installation Bundler (We

Mario Juárez 982 Dec 16, 2022
Mobile friendly datetime picker for Vue. Supports date and datetime modes, i18n and disabling dates.

Mobile friendly datetime picker for Vue. Supports date, datetime and time modes, i18n and disabling dates.

null 0 May 1, 2020
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
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
An easy-to-use and customizable date picker component powered by Vue js

vue-datepicker An easy-to-use and customizable date picker component powered by Vue js Demo:s https://codesandbox.io/s/eager-rubin-5zcm9 Install npm i

Krijan Niroula 2 Dec 4, 2021
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
Not your ordinary datepicker. A Vuejs draggable date selector with a fresh responsive design, mobile ready and 0 dependencies, 17kb gzipped

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

Tom 86 Dec 1, 2022
A vue date picker component inspired by material design

Vue Date Picker A vue date picker component inspired by material design Contents Installing Examples Formatting Selected Date API Installing $ npm ins

Trevor Stacy 56 Nov 16, 2022
Vue date range picker component

A responsive date range picker for Vue.js that displays the number of nights selected and allow several useful options like custom check-in/check-out

Krystal Campioni 769 Dec 29, 2022
A vue component using Bootstrap 4 styles for date range selection

vue-date-range-picker A vue component using Bootstrap 4 styles for date range selection Live demo (jsfiddle) Features Date range selection Compare fea

Antoine Matyja 28 Nov 23, 2022