From bf779c3c199559c8a7ea7b7b08f9f100668494e9 Mon Sep 17 00:00:00 2001 From: Arash Mousavi Date: Mon, 18 Aug 2014 00:53:25 +0430 Subject: [PATCH] update JDate to latest version --- build/js/jcal.js | 64 ++++++++++--------- build/js/jcal.min.js | 2 +- component.json | 2 +- .../jdate/{master => v0.1.1}/component.json | 2 +- .../arashm/jdate/{master => v0.1.1}/index.js | 0 .../jdate/{master => v0.1.1}/lib/converter.js | 0 .../jdate/{master => v0.1.1}/lib/jdate.js | 8 ++- 7 files changed, 41 insertions(+), 37 deletions(-) rename components/arashm/jdate/{master => v0.1.1}/component.json (94%) rename components/arashm/jdate/{master => v0.1.1}/index.js (100%) rename components/arashm/jdate/{master => v0.1.1}/lib/converter.js (100%) rename components/arashm/jdate/{master => v0.1.1}/lib/jdate.js (98%) diff --git a/build/js/jcal.js b/build/js/jcal.js index 2bf3b24..ffb04fb 100755 --- a/build/js/jcal.js +++ b/build/js/jcal.js @@ -957,13 +957,35 @@ exports.normalize = function (event) { }); -require.register("arashm~jdate@master", function (exports, module) { -module.exports = require("arashm~jdate@master/lib/jdate.js"); +require.register("component~in-groups-of@1.0.0", function (exports, module) { + +module.exports = function(arr, n){ + var ret = []; + var group = []; + var len = arr.length; + var per = len * (n / len); + + for (var i = 0; i < len; ++i) { + group.push(arr[i]); + if ((i + 1) % n == 0) { + ret.push(group); + group = []; + } + } + + if (group.length) ret.push(group); + + return ret; +}; +}); + +require.register("arashm~jdate@v0.1.1", function (exports, module) { +module.exports = require("arashm~jdate@v0.1.1/lib/jdate.js"); }); -require.register("arashm~jdate@master/lib/converter.js", function (exports, module) { +require.register("arashm~jdate@v0.1.1/lib/converter.js", function (exports, module) { (function (root) { /* @@ -1182,13 +1204,13 @@ function d2g(jdn) { }); -require.register("arashm~jdate@master/lib/jdate.js", function (exports, module) { +require.register("arashm~jdate@v0.1.1/lib/jdate.js", function (exports, module) { /* * https://github.com/arashm/JDate * @author: Arash Mousavi - * @version: 0.1.0 + * @version: 0.1.1 */ -var jalali = require("arashm~jdate@master/lib/converter.js") +var jalali = require("arashm~jdate@v0.1.1/lib/converter.js") , map = require("component~map@0.0.1"); module.exports = JDate; @@ -1426,10 +1448,12 @@ JDate.daysInMonth = function (year, month) { if (month < 0) { month += 12 year -= 1 + } else if (month == 0) { + month = 12 } - if (month < 6) { + if (month <= 6) { return 31 - } else if (month < 11) { + } else if (month <= 11) { return 30 } else if (JDate.isLeapYear(year)) { return 30 @@ -1441,28 +1465,6 @@ JDate.daysInMonth = function (year, month) { }); -require.register("component~in-groups-of@1.0.0", function (exports, module) { - -module.exports = function(arr, n){ - var ret = []; - var group = []; - var len = arr.length; - var per = len * (n / len); - - for (var i = 0; i < len; ++i) { - group.push(arr[i]); - if ((i + 1) % n == 0) { - ret.push(group); - group = []; - } - } - - if (group.length) ret.push(group); - - return ret; -}; -}); - require.register("jcal", function (exports, module) { module.exports = require("jcal/lib/jcal.js"); @@ -1475,7 +1477,7 @@ var event = require("component~event@0.1.4") , domify = require("component~domify@1.2.2") , template = require("jcal/lib/template.js") , classes = require("component~classes@1.2.1") - , jdate = require("arashm~jdate@master") + , jdate = require("arashm~jdate@v0.1.1") , inGroupsOf = require("component~in-groups-of@1.0.0") , Emitter = require("component~emitter@1.1.3") , normalize = require("stephenmathieson~normalize@0.0.1") diff --git a/build/js/jcal.min.js b/build/js/jcal.min.js index 5331cf8..c5d3507 100755 --- a/build/js/jcal.min.js +++ b/build/js/jcal.min.js @@ -1 +1 @@ -function require(t){var e=require.modules[t];if(!e)throw new Error('failed to require "'+t+'"');return"exports"in e||"function"!=typeof e.definition||(e.client=e.component=!0,e.definition.call(this,e.exports={},e),delete e.definition),e.exports}require.modules={},require.register=function(t,e){require.modules[t]={definition:e}},require.define=function(t,e){require.modules[t]={exports:e}},require.register("component~emitter@1.1.3",function(t,e){function r(t){return t?n(t):void 0}function n(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}e.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},r.prototype.once=function(t,e){function r(){n.off(t,r),e.apply(this,arguments)}var n=this;return this._callbacks=this._callbacks||{},r.fn=e,this.on(t,r),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks[t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var n,i=0;in;++n)r[n].apply(this,e)}return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}}),require.register("component~event@0.1.4",function(t){var e=window.addEventListener?"addEventListener":"attachEvent",r=window.removeEventListener?"removeEventListener":"detachEvent",n="addEventListener"!==e?"on":"";t.bind=function(t,r,i,o){return t[e](n+r,i,o||!1),i},t.unbind=function(t,e,i,o){return t[r](n+e,i,o||!1),i}}),require.register("component~domify@1.2.2",function(t,e){function r(t){if("string"!=typeof t)throw new TypeError("String expected");var e=/<([\w:]+)/.exec(t);if(!e)return document.createTextNode(t);t=t.replace(/^\s+|\s+$/g,"");var r=e[1];if("body"==r){var i=document.createElement("html");return i.innerHTML=t,i.removeChild(i.lastChild)}var o=n[r]||n._default,a=o[0],s=o[1],c=o[2],i=document.createElement("div");for(i.innerHTML=s+t+c;a--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);for(var l=document.createDocumentFragment();i.firstChild;)l.appendChild(i.removeChild(i.firstChild));return l}e.exports=r;var n={legend:[1,"
","
"],tr:[2,"","
"],col:[2,"","
"],_default:[0,"",""]};n.td=n.th=[3,"","
"],n.option=n.optgroup=[1,'"],n.thead=n.tbody=n.colgroup=n.caption=n.tfoot=[1,"","
"],n.text=n.circle=n.ellipse=n.line=n.path=n.polygon=n.polyline=n.rect=[1,'',""]}),require.register("component~indexof@0.0.3",function(t,e){e.exports=function(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0;rt||t>=u[h-1])throw new Error("Invalid Jalaali year "+t);for(l=1;h>l&&(e=u[l],r=e-p,!(e>t));l+=1)f=f+8*n(r,33)+n(i(r,33),4),p=e;return c=t-p,f=f+8*n(c,33)+n(i(c,33)+3,4),4===i(r,33)&&r-c===4&&(f+=1),a=n(d,4)-n(3*(n(d,100)+1),4)-150,s=20+f-a,6>r-c&&(c=c-r+33*n(r+4,33)),o=i(i(c+1,33)-1,4),-1===o&&(o=4),{leap:o,gy:d,march:s}}function a(t,e,r){var i=o(t);return c(i.gy,3,i.march)+31*(e-1)-n(e,7)*(e-7)+r-1}function s(t){var e,r,a,s=l(t).gy,u=s-621,h=o(u),d=c(s,3,h.march);if(a=t-d,a>=0){if(185>=a)return r=1+n(a,31),e=i(a,31)+1,{jy:u,jm:r,jd:e};a-=186}else u-=1,a+=179,1===h.leap&&(a+=1);return r=7+n(a,30),e=i(a,30)+1,{jy:u,jm:r,jd:e}}function c(t,e,r){var o=n(1461*(t+n(e-8,6)+100100),4)+n(153*i(e+9,12)+2,5)+r-34840408;return o=o-n(3*n(t+100100+n(e-8,6),100),4)+752}function l(t){var e,r,o,a,s;return e=4*t+139361631,e=e+4*n(3*n(4*t+183187720,146097),4)-3908,r=5*n(i(e,1461),4)+308,o=n(i(r,153),5)+1,a=i(n(r,153),12)+1,s=n(e,1461)-100100+n(8-a,6),{gy:s,gm:a,gd:o}}var u={jalCal:o,j2d:a,d2j:s,g2d:c,d2g:l};"object"==typeof t?e.exports=u:r.jalaali=u}(this)}),require.register("arashm~jdate@master/lib/jdate.js",function(t,e){function r(t){this._d=t||new Date,this._d instanceof Array?(this.date=i(this._d,function(t){return parseInt(t)}),this._d=this.to_gregorian()):this._d instanceof Date&&(this.date=r.to_jalali(this._d))}var n=require("arashm~jdate@master/lib/converter.js"),i=require("component~map@0.0.1");e.exports=r;var o=["فروردین","اردیبهشت","خرداد","تیر","امرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"],a=["۱ش","۲ش","۳ش","۴ش","۵ش","ج","ش"],s=["یکشنبه","دوشنبه","سه‌شنبه","چهارشنبه","پنج‌شنبه","جمعه","شنبه"],c=function(t,e){if(e>12||0>=e){var r=Math.floor((e-1)/12);t+=r,e-=12*r}return[t,e]},l=function(t,e){if(match=t.match(/[yY]+/),!match)return t;switch(match[0]){case"YYYY":case"YYY":var r=l(t.replace(match,e.getFullYear()),e);return r;case"YY":var r=l(t.replace(match,String(e.getFullYear()).slice(2)),e);return r}},u=function(t,e){if(match=t.match(/[mM]+/),!match)return t;switch(match[0]){case"M":case"MM":var r=u(t.replace(match,e.getMonth()),e);return r;case"MMM":case"MMMM":var r=u(t.replace(match,o[e.getMonth()-1]),e);return r}},h=function(t,e){if(match=t.match(/[dD]+/),!match)return t;switch(match[0]){case"D":case"DD":var r=h(t.replace(match,e.getDate()),e);return r;case"d":case"dd":var r=h(t.replace(match,a[e.getDay()]),e);return r;case"ddd":case"dddd":var r=h(t.replace(match,s[e.getDay()]),e);return r}};r.prototype.to_gregorian=function(){return r.to_gregorian(this.date[0],this.date[1],this.date[2])},r.prototype.getFullYear=function(){return this.date[0]},r.prototype.setFullYear=function(t){return this.date[0]=parseInt(t),this._d=this.to_gregorian(),this},r.prototype.getMonth=function(){return this.date[1]},r.prototype.setMonth=function(t){return fixed=c(this.getFullYear(),parseInt(t)),this.date[0]=fixed[0],this.date[1]=fixed[1],this._d=this.to_gregorian(),this},r.prototype.getDate=function(){return this.date[2]},r.prototype.setDate=function(t){return this.date[2]=parseInt(t),this._d=this.to_gregorian(),this},r.prototype.getDay=function(){return this._d.getDay()},r.prototype.format=function(t){return t=l(t,this),t=u(t,this),t=h(t,this)},r.to_jalali=function(t){var e=n.d2j(n.g2d(t.getFullYear(),t.getMonth()+1,t.getDate()));return[e.jy,e.jm,e.jd]},r.to_gregorian=function(t,e,r){var i=n.d2g(n.j2d(t,e,r));return new Date(i.gy,i.gm-1,i.gd)},r.isLeapYear=function(t){return 0===n.jalCal(t).leap},r.daysInMonth=function(t,e){return t+=~~(e/12),e-=12*~~(e/12),0>e&&(e+=12,t-=1),6>e?31:11>e?30:r.isLeapYear(t)?30:29}}),require.register("component~in-groups-of@1.0.0",function(t,e){e.exports=function(t,e){for(var r=[],n=[],i=t.length,o=0;i>o;++o)n.push(t[o]),(o+1)%e==0&&(r.push(n),n=[]);return n.length&&r.push(n),r}}),require.register("jcal",function(t,e){e.exports=require("jcal/lib/jcal.js")}),require.register("jcal/lib/jcal.js",function(t,e){function r(t){return this instanceof r?(u.call(this),self=this,this._c=i.merge(defaults,t),this.el=this._c.field,this.cal=o(a),this.head=this.cal.tHead,this.header=this.head.querySelector(".jcal-title"),this.title=this.head.querySelector(".jcal-controls__year"),this.body=this.cal.tBodies[0],this.on("prev",this.prev),this.on("next",this.next),this.show(this._c.initialDate),n.bind(this.el.querySelector(".jcal-controls__prev"),"click",h(function(t){return t.preventDefault(),self.emit("prev"),!1})),n.bind(this.el.querySelector(".jcal-controls__next"),"click",h(function(t){return t.preventDefault(),self.emit("next"),!1})),void n.bind(this.body,"click",h(function(t){t.preventDefault();var e=t.target,r=new c(e.getAttribute("data-date").split("-"));return self.body.querySelector(".jcal-body__day--selected")&&s(self.body.querySelector(".jcal-body__day--selected")).remove("jcal-body__day--selected"),s(e).add("jcal-body__day--selected"),self.select(r),self.emit("change",r),!1}))):new r(t)}var n=require("component~event@0.1.4"),i=require("component~object@0.0.3"),o=require("component~domify@1.2.2"),a=require("jcal/lib/template.js"),s=require("component~classes@1.2.1"),c=require("arashm~jdate@master"),l=require("component~in-groups-of@1.0.0"),u=require("component~emitter@1.1.3"),h=require("stephenmathieson~normalize@0.0.1"),d=require("component~map@0.0.1");e.exports=r;var f=function(t,e){for(var r=[],n=0;n"+t[n]+"");return r},p=function(t,e,r,n,i,o){var a=[];return o?"":(n&&a.push("jcal-body__day--selected"),i&&a.push("jcal-body__day--today"),""+r+"")},g=function(t){return""+t.join("\n")+""},y=function(t,e){date=new c([t,e,1]),today=new c,days_in_month=c.daysInMonth(date.getFullYear(),date.getMonth()),console.log([days_in_month,date.getFullYear(),date.getMonth()]),starting_day_of_month=date._d.getDay(),ending_day_of_month=new c([t,e,days_in_month])._d.getDay(),empty_cells_before=6>starting_day_of_month?starting_day_of_month+1:0,empty_cells_after=6>ending_day_of_month?ending_day_of_month-5:6;for(var r=[],n=0;empty_cells_before>n;++n)r.push(p(t,e,n,!1,!1,!0));for(var n=1;days_in_month>=n;++n)is_today=t==today.getFullYear()&&e==today.getMonth()&&n==today.getDate()?!0:!1,r.push(p(t,e,n,!1,is_today));for(var n=0;empty_cells_after>n;++n)r.push(p(t,e,n,!1,!1,!0));r=l(r,7);var i=d(r,function(t){return g(t)});return i};defaults={field:document.querySelector("body"),initialDate:new c,showAbbreviated:!0,title_format:"MMMM YYYY",l10n_short_days:["ش","۱ش","۲ش","۳ش","۴ش","۵ش","ج"],l10n_long_days:["شنبه","یکشنبه","دوشنبه","سه‌شنبه","چهارشنبه","پنج‌شنبه","جمعه"]},u(r.prototype),r.prototype.show=function(t){return this._date=t._d?t:new c(t),this.header.innerHTML=this._c.showAbbreviated?f(this._c.l10n_short_days,this._c.l10n_long_days).join("\n"):f(this._c.l10n_long_days,this._c.l10n_long_days).join("\n"),this.body.innerHTML=y(this._date.getFullYear(),this._date.getMonth()).join("\n"),this.updateTitle(),this.el.appendChild(this.cal),this},r.prototype.prevMonth=function(){return date=this._date,console.log(date),date.setMonth(date.getMonth()-1),date},r.prototype.nextMonth=function(){return date=this._date,date.setMonth(date.getMonth()+1),date},r.prototype.prev=function(){return this.show(this.prevMonth()),this},r.prototype.next=function(){return this.show(this.nextMonth()),this},r.prototype.updateTitle=function(){return this.title.textContent=this._date.format(this._c.title_format),this},r.prototype.select=function(t){return this.selected=t,this}}),require.register("jcal/lib/template.js",function(t,e){e.exports="
"}),require("jcal"); \ No newline at end of file +function require(t){var e=require.modules[t];if(!e)throw new Error('failed to require "'+t+'"');return"exports"in e||"function"!=typeof e.definition||(e.client=e.component=!0,e.definition.call(this,e.exports={},e),delete e.definition),e.exports}require.modules={},require.register=function(t,e){require.modules[t]={definition:e}},require.define=function(t,e){require.modules[t]={exports:e}},require.register("component~emitter@1.1.3",function(t,e){function r(t){return t?n(t):void 0}function n(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}e.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},r.prototype.once=function(t,e){function r(){n.off(t,r),e.apply(this,arguments)}var n=this;return this._callbacks=this._callbacks||{},r.fn=e,this.on(t,r),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks[t];if(!r)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var n,i=0;in;++n)r[n].apply(this,e)}return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}}),require.register("component~event@0.1.4",function(t){var e=window.addEventListener?"addEventListener":"attachEvent",r=window.removeEventListener?"removeEventListener":"detachEvent",n="addEventListener"!==e?"on":"";t.bind=function(t,r,i,o){return t[e](n+r,i,o||!1),i},t.unbind=function(t,e,i,o){return t[r](n+e,i,o||!1),i}}),require.register("component~domify@1.2.2",function(t,e){function r(t){if("string"!=typeof t)throw new TypeError("String expected");var e=/<([\w:]+)/.exec(t);if(!e)return document.createTextNode(t);t=t.replace(/^\s+|\s+$/g,"");var r=e[1];if("body"==r){var i=document.createElement("html");return i.innerHTML=t,i.removeChild(i.lastChild)}var o=n[r]||n._default,a=o[0],s=o[1],c=o[2],i=document.createElement("div");for(i.innerHTML=s+t+c;a--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);for(var l=document.createDocumentFragment();i.firstChild;)l.appendChild(i.removeChild(i.firstChild));return l}e.exports=r;var n={legend:[1,"
","
"],tr:[2,"","
"],col:[2,"","
"],_default:[0,"",""]};n.td=n.th=[3,"","
"],n.option=n.optgroup=[1,'"],n.thead=n.tbody=n.colgroup=n.caption=n.tfoot=[1,"","
"],n.text=n.circle=n.ellipse=n.line=n.path=n.polygon=n.polyline=n.rect=[1,'',""]}),require.register("component~indexof@0.0.3",function(t,e){e.exports=function(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0;ro;++o)n.push(t[o]),(o+1)%e==0&&(r.push(n),n=[]);return n.length&&r.push(n),r}}),require.register("arashm~jdate@v0.1.1",function(t,e){e.exports=require("arashm~jdate@v0.1.1/lib/jdate.js")}),require.register("arashm~jdate@v0.1.1/lib/converter.js",function(t,e){!function(r){function n(t,e){return~~(t/e)}function i(t,e){return t-~~(t/e)*e}function o(t){var e,r,o,a,s,c,l,u=[-61,9,38,199,426,686,756,818,1111,1181,1210,1635,2060,2097,2192,2262,2324,2394,2456,3178],h=u.length,d=t+621,f=-14,p=u[0];if(p>t||t>=u[h-1])throw new Error("Invalid Jalaali year "+t);for(l=1;h>l&&(e=u[l],r=e-p,!(e>t));l+=1)f=f+8*n(r,33)+n(i(r,33),4),p=e;return c=t-p,f=f+8*n(c,33)+n(i(c,33)+3,4),4===i(r,33)&&r-c===4&&(f+=1),a=n(d,4)-n(3*(n(d,100)+1),4)-150,s=20+f-a,6>r-c&&(c=c-r+33*n(r+4,33)),o=i(i(c+1,33)-1,4),-1===o&&(o=4),{leap:o,gy:d,march:s}}function a(t,e,r){var i=o(t);return c(i.gy,3,i.march)+31*(e-1)-n(e,7)*(e-7)+r-1}function s(t){var e,r,a,s=l(t).gy,u=s-621,h=o(u),d=c(s,3,h.march);if(a=t-d,a>=0){if(185>=a)return r=1+n(a,31),e=i(a,31)+1,{jy:u,jm:r,jd:e};a-=186}else u-=1,a+=179,1===h.leap&&(a+=1);return r=7+n(a,30),e=i(a,30)+1,{jy:u,jm:r,jd:e}}function c(t,e,r){var o=n(1461*(t+n(e-8,6)+100100),4)+n(153*i(e+9,12)+2,5)+r-34840408;return o=o-n(3*n(t+100100+n(e-8,6),100),4)+752}function l(t){var e,r,o,a,s;return e=4*t+139361631,e=e+4*n(3*n(4*t+183187720,146097),4)-3908,r=5*n(i(e,1461),4)+308,o=n(i(r,153),5)+1,a=i(n(r,153),12)+1,s=n(e,1461)-100100+n(8-a,6),{gy:s,gm:a,gd:o}}var u={jalCal:o,j2d:a,d2j:s,g2d:c,d2g:l};"object"==typeof t?e.exports=u:r.jalaali=u}(this)}),require.register("arashm~jdate@v0.1.1/lib/jdate.js",function(t,e){function r(t){this._d=t||new Date,this._d instanceof Array?(this.date=i(this._d,function(t){return parseInt(t)}),this._d=this.to_gregorian()):this._d instanceof Date&&(this.date=r.to_jalali(this._d))}var n=require("arashm~jdate@v0.1.1/lib/converter.js"),i=require("component~map@0.0.1");e.exports=r;var o=["فروردین","اردیبهشت","خرداد","تیر","امرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"],a=["۱ش","۲ش","۳ش","۴ش","۵ش","ج","ش"],s=["یکشنبه","دوشنبه","سه‌شنبه","چهارشنبه","پنج‌شنبه","جمعه","شنبه"],c=function(t,e){if(e>12||0>=e){var r=Math.floor((e-1)/12);t+=r,e-=12*r}return[t,e]},l=function(t,e){if(match=t.match(/[yY]+/),!match)return t;switch(match[0]){case"YYYY":case"YYY":var r=l(t.replace(match,e.getFullYear()),e);return r;case"YY":var r=l(t.replace(match,String(e.getFullYear()).slice(2)),e);return r}},u=function(t,e){if(match=t.match(/[mM]+/),!match)return t;switch(match[0]){case"M":case"MM":var r=u(t.replace(match,e.getMonth()),e);return r;case"MMM":case"MMMM":var r=u(t.replace(match,o[e.getMonth()-1]),e);return r}},h=function(t,e){if(match=t.match(/[dD]+/),!match)return t;switch(match[0]){case"D":case"DD":var r=h(t.replace(match,e.getDate()),e);return r;case"d":case"dd":var r=h(t.replace(match,a[e.getDay()]),e);return r;case"ddd":case"dddd":var r=h(t.replace(match,s[e.getDay()]),e);return r}};r.prototype.to_gregorian=function(){return r.to_gregorian(this.date[0],this.date[1],this.date[2])},r.prototype.getFullYear=function(){return this.date[0]},r.prototype.setFullYear=function(t){return this.date[0]=parseInt(t),this._d=this.to_gregorian(),this},r.prototype.getMonth=function(){return this.date[1]},r.prototype.setMonth=function(t){return fixed=c(this.getFullYear(),parseInt(t)),this.date[0]=fixed[0],this.date[1]=fixed[1],this._d=this.to_gregorian(),this},r.prototype.getDate=function(){return this.date[2]},r.prototype.setDate=function(t){return this.date[2]=parseInt(t),this._d=this.to_gregorian(),this},r.prototype.getDay=function(){return this._d.getDay()},r.prototype.format=function(t){return t=l(t,this),t=u(t,this),t=h(t,this)},r.to_jalali=function(t){var e=n.d2j(n.g2d(t.getFullYear(),t.getMonth()+1,t.getDate()));return[e.jy,e.jm,e.jd]},r.to_gregorian=function(t,e,r){var i=n.d2g(n.j2d(t,e,r));return new Date(i.gy,i.gm-1,i.gd)},r.isLeapYear=function(t){return 0===n.jalCal(t).leap},r.daysInMonth=function(t,e){return t+=~~(e/12),e-=12*~~(e/12),0>e?(e+=12,t-=1):0==e&&(e=12),6>=e?31:11>=e?30:r.isLeapYear(t)?30:29}}),require.register("jcal",function(t,e){e.exports=require("jcal/lib/jcal.js")}),require.register("jcal/lib/jcal.js",function(t,e){function r(t){return this instanceof r?(u.call(this),self=this,this._c=i.merge(defaults,t),this.el=this._c.field,this.cal=o(a),this.head=this.cal.tHead,this.header=this.head.querySelector(".jcal-title"),this.title=this.head.querySelector(".jcal-controls__year"),this.body=this.cal.tBodies[0],this.on("prev",this.prev),this.on("next",this.next),this.show(this._c.initialDate),n.bind(this.el.querySelector(".jcal-controls__prev"),"click",h(function(t){return t.preventDefault(),self.emit("prev"),!1})),n.bind(this.el.querySelector(".jcal-controls__next"),"click",h(function(t){return t.preventDefault(),self.emit("next"),!1})),void n.bind(this.body,"click",h(function(t){t.preventDefault();var e=t.target,r=new c(e.getAttribute("data-date").split("-"));return self.body.querySelector(".jcal-body__day--selected")&&s(self.body.querySelector(".jcal-body__day--selected")).remove("jcal-body__day--selected"),s(e).add("jcal-body__day--selected"),self.select(r),self.emit("change",r),!1}))):new r(t)}var n=require("component~event@0.1.4"),i=require("component~object@0.0.3"),o=require("component~domify@1.2.2"),a=require("jcal/lib/template.js"),s=require("component~classes@1.2.1"),c=require("arashm~jdate@v0.1.1"),l=require("component~in-groups-of@1.0.0"),u=require("component~emitter@1.1.3"),h=require("stephenmathieson~normalize@0.0.1"),d=require("component~map@0.0.1");e.exports=r;var f=function(t,e){for(var r=[],n=0;n"+t[n]+"");return r},p=function(t,e,r,n,i,o){var a=[];return o?"":(n&&a.push("jcal-body__day--selected"),i&&a.push("jcal-body__day--today"),""+r+"")},g=function(t){return""+t.join("\n")+""},y=function(t,e){date=new c([t,e,1]),today=new c,days_in_month=c.daysInMonth(date.getFullYear(),date.getMonth()),console.log([days_in_month,date.getFullYear(),date.getMonth()]),starting_day_of_month=date._d.getDay(),ending_day_of_month=new c([t,e,days_in_month])._d.getDay(),empty_cells_before=6>starting_day_of_month?starting_day_of_month+1:0,empty_cells_after=6>ending_day_of_month?ending_day_of_month-5:6;for(var r=[],n=0;empty_cells_before>n;++n)r.push(p(t,e,n,!1,!1,!0));for(var n=1;days_in_month>=n;++n)is_today=t==today.getFullYear()&&e==today.getMonth()&&n==today.getDate()?!0:!1,r.push(p(t,e,n,!1,is_today));for(var n=0;empty_cells_after>n;++n)r.push(p(t,e,n,!1,!1,!0));r=l(r,7);var i=d(r,function(t){return g(t)});return i};defaults={field:document.querySelector("body"),initialDate:new c,showAbbreviated:!0,title_format:"MMMM YYYY",l10n_short_days:["ش","۱ش","۲ش","۳ش","۴ش","۵ش","ج"],l10n_long_days:["شنبه","یکشنبه","دوشنبه","سه‌شنبه","چهارشنبه","پنج‌شنبه","جمعه"]},u(r.prototype),r.prototype.show=function(t){return this._date=t._d?t:new c(t),this.header.innerHTML=this._c.showAbbreviated?f(this._c.l10n_short_days,this._c.l10n_long_days).join("\n"):f(this._c.l10n_long_days,this._c.l10n_long_days).join("\n"),this.body.innerHTML=y(this._date.getFullYear(),this._date.getMonth()).join("\n"),this.updateTitle(),this.el.appendChild(this.cal),this},r.prototype.prevMonth=function(){return date=this._date,console.log(date),date.setMonth(date.getMonth()-1),date},r.prototype.nextMonth=function(){return date=this._date,date.setMonth(date.getMonth()+1),date},r.prototype.prev=function(){return this.show(this.prevMonth()),this},r.prototype.next=function(){return this.show(this.nextMonth()),this},r.prototype.updateTitle=function(){return this.title.textContent=this._date.format(this._c.title_format),this},r.prototype.select=function(t){return this.selected=t,this}}),require.register("jcal/lib/template.js",function(t,e){e.exports="
"}),require("jcal"); \ No newline at end of file diff --git a/component.json b/component.json index 0f6e212..1524bd4 100644 --- a/component.json +++ b/component.json @@ -28,6 +28,6 @@ "component/in-groups-of": "1.0.0", "component/object": "*", "stephenmathieson/normalize": "*", - "arashm/jdate": "*" + "arashm/jdate": "v0.1.1" } } diff --git a/components/arashm/jdate/master/component.json b/components/arashm/jdate/v0.1.1/component.json similarity index 94% rename from components/arashm/jdate/master/component.json rename to components/arashm/jdate/v0.1.1/component.json index 3035806..712abe5 100644 --- a/components/arashm/jdate/master/component.json +++ b/components/arashm/jdate/v0.1.1/component.json @@ -1,6 +1,6 @@ { "name": "jdate", - "version": "0.1.0", + "version": "0.1.1", "description": "A Jalali to Gregorian converter with support of formatting output", "keywords": [ "date", diff --git a/components/arashm/jdate/master/index.js b/components/arashm/jdate/v0.1.1/index.js similarity index 100% rename from components/arashm/jdate/master/index.js rename to components/arashm/jdate/v0.1.1/index.js diff --git a/components/arashm/jdate/master/lib/converter.js b/components/arashm/jdate/v0.1.1/lib/converter.js similarity index 100% rename from components/arashm/jdate/master/lib/converter.js rename to components/arashm/jdate/v0.1.1/lib/converter.js diff --git a/components/arashm/jdate/master/lib/jdate.js b/components/arashm/jdate/v0.1.1/lib/jdate.js similarity index 98% rename from components/arashm/jdate/master/lib/jdate.js rename to components/arashm/jdate/v0.1.1/lib/jdate.js index 333a325..9f46c14 100644 --- a/components/arashm/jdate/master/lib/jdate.js +++ b/components/arashm/jdate/v0.1.1/lib/jdate.js @@ -1,7 +1,7 @@ /* * https://github.com/arashm/JDate * @author: Arash Mousavi - * @version: 0.1.0 + * @version: 0.1.1 */ var jalali = require('./converter') , map = require('map'); @@ -241,10 +241,12 @@ JDate.daysInMonth = function (year, month) { if (month < 0) { month += 12 year -= 1 + } else if (month == 0) { + month = 12 } - if (month < 6) { + if (month <= 6) { return 31 - } else if (month < 11) { + } else if (month <= 11) { return 30 } else if (JDate.isLeapYear(year)) { return 30