UNPKG

owltech

Version:
46 lines (41 loc) 1.99 kB
/** * @preserve date-and-time.js locale configuration * @preserve Persian (fa) * @preserve It is using moment.js locale configuration as a reference. */ (function (global) { 'use strict'; var locale = function (date) { var num = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'], map = { '۰': 0, '۱': 1, '۲': 2, '۳': 3, '۴': 4, '۵': 5, '۶': 6, '۷': 7, '۸': 8, '۹': 9 }; date.setLocales('fa', { MMMM: ['ژانویه', 'فوریه', 'مارس', 'آوریل', 'مه', 'ژوئن', 'ژوئیه', 'اوت', 'سپتامبر', 'اکتبر', 'نوامبر', 'دسامبر'], MMM: ['ژانویه', 'فوریه', 'مارس', 'آوریل', 'مه', 'ژوئن', 'ژوئیه', 'اوت', 'سپتامبر', 'اکتبر', 'نوامبر', 'دسامبر'], dddd: ['یک‌شنبه', 'دوشنبه', 'سه‌شنبه', 'چهارشنبه', 'پنج‌شنبه', 'جمعه', 'شنبه'], ddd: ['یک‌شنبه', 'دوشنبه', 'سه‌شنبه', 'چهارشنبه', 'پنج‌شنبه', 'جمعه', 'شنبه'], dd: ['ی', 'د', 'س', 'چ', 'پ', 'ج', 'ش'], A: ['قبل از ظهر', 'بعد از ظهر'], formatter: { post: function (str) { return str.replace(/\d/g, function (i) { return num[i | 0]; }); } }, parser: { pre: function (str) { return str.replace(/[۰۱۲۳۴۵۶۷۸۹]/g, function (i) { return '' + map[i]; }); } } }); }; if (typeof module === 'object' && typeof module.exports === 'object') { locale(require('../date-and-time')); } else if (typeof define === 'function' && define.amd) { define(['date-and-time'], locale); } else { locale(global.date); } }(this));