PageSourceSearch

https://online.myparvaz.com/Scripts/MdBootstrapPersianDateTimePicker/calendar.js?v=202610070817

js myparvaz.com collected 2026-10-08 16:17:41 UTC 5,626 bytes, 168 lines download raw bytes

1/*
2Jalali (Shamsi) Calendar Date Picker Version 1.00 (JavaScript)
3-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
4Written By : Amin Habibi Shahri
5E-mail : [email protected]
6Homepage: http://habibiamin.googlepages.com
7*/
8
9/*  MOD  --  Modulus function which works for non-integers.  */
10
11function mod(a, b) {
12    return a - (b * Math.floor(a / b));
13}
14
15function jwday(j) {
16    return mod(Math.floor((j + 1.5)), 7);
17}
18
19var Weekdays = new Array("Sunday", "Monday", "Tuesday", "Wednesday",
20                          "Thursday", "Friday", "Saturday");
21
22//  LEAP_GREGORIAN  --  Is a given year in the Gregorian calendar a leap year ?
23
24function leap_gregorian(year) {
25    return ((year % 4) == 0) &&
26            (!(((year % 100) == 0) && ((year % 400) != 0)));
27}
28
29//  GREGORIAN_TO_JD  --  Determine Julian day number from Gregorian calendar date
30
31var GREGORIAN_EPOCH = 1721425.5;
32
33function gregorian_to_jd(year, month, day) {
34    return (GREGORIAN_EPOCH - 1) +
35           (365 * (year - 1)) +
36           Math.floor((year - 1) / 4) +
37           (-Math.floor((year - 1) / 100)) +
38           Math.floor((year - 1) / 400) +
39           Math.floor((((367 * month) - 362) / 12) +
40           ((month <= 2) ? 0 :
41                               (leap_gregorian(year) ? -1 : -2)
42           ) +
43           day);
44}
45
46//  JD_TO_GREGORIAN  --  Calculate Gregorian calendar date from Julian day
47
48function jd_to_gregorian(jd) {
49    var wjd, depoch, quadricent, dqc, cent, dcent, quad, dquad,
50        yindex, year, yearday, leapadj;
51
52    wjd = Math.floor(jd - 0.5) + 0.5;
53    depoch = wjd - GREGORIAN_EPOCH;
54    quadricent = Math.floor(depoch / 146097);
55    dqc = mod(depoch, 146097);
56    cent = Math.floor(dqc / 36524);
57    dcent = mod(dqc, 36524);
58    quad = Math.floor(dcent / 1461);
59    dquad = mod(dcent, 1461);
60    yindex = Math.floor(dquad / 365);
61    year = (quadricent * 400) + (cent * 100) + (quad * 4) + yindex;
62    if (!((cent == 4) || (yindex == 4))) {
63        year++;
64    }
65    yearday = wjd - gregorian_to_jd(year, 1, 1);
66    leapadj = ((wjd < gregorian_to_jd(year, 3, 1)) ? 0
67                                                  :
68                  (leap_gregorian(year) ? 1 : 2)
69              );
70    var month = Math.floor((((yearday + leapadj) * 12) + 373) / 367);
71    var day = (wjd - gregorian_to_jd(year, month, 1)) + 1;
72
73    return new Array(year, month, day);
74}
75
76//  LEAP_PERSIAN  --  Is a given year a leap year in the Persian calendar ?
77
78function leap_persian(year) {
79    return ((((((year - ((year > 0) ? 474 : 473)) % 2820) + 474) + 38) * 682) % 2816) < 682;
80}
81
82//  PERSIAN_TO_JD  --  Determine Julian day from Persian date
83
84var PERSIAN_EPOCH = 1948320.5;
85var PERSIAN_WEEKDAYS = new Array("دوشنبه", "یکشنبه",
86                                 "چهارشنبه", "سه شنبه",
87                                 "شنبه", "جمعه", "پنج شنبه");
88
89function persian_to_jd(year, month, day) {
90    var epbase, epyear;
91    epbase = year - ((year >= 0) ? 474 : 473);
92    epyear = 474 + mod(epbase, 2820);
93    return day +
94            ((month <= 7) ?
95                ((month - 1) * 31) :
96                (((month - 1) * 30) + 6)
97            ) +
98            Math.floor(((epyear * 682) - 110) / 2816) +
99            (epyear - 1) * 365 +
100            Math.floor(epbase / 2820) * 1029983 +
101            (PERSIAN_EPOCH - 1);
102}
103
104//  JD_TO_PERSIAN  --  Calculate Persian date from Julian day
105
106function jd_to_persian(jd) {
107    var year, month, day, depoch, cycle, cyear, ycycle,
108        aux1, aux2, yday;
109    jd = Math.floor(jd) + 0.5;
110    depoch = jd - persian_to_jd(475, 1, 1);
111    cycle = Math.floor(depoch / 1029983);
112    cyear = mod(depoch, 1029983);
113    if (cyear == 1029982) {
114        ycycle = 2820;
115    } else {
116        aux1 = Math.floor(cyear / 366);
117        aux2 = mod(cyear, 366);
118        ycycle = Math.floor(((2134 * aux1) + (2816 * aux2) + 2815) / 1028522) + aux1 + 1;
119    }
120    year = ycycle + (2820 * cycle) + 474;
121    if (year <= 0) {
122        year--;
123    }
124    yday = (jd - persian_to_jd(year, 1, 1)) + 1;
125    month = (yday <= 186) ? Math.ceil(yday / 31) : Math.ceil((yday - 6) / 30);
126    day = (jd - persian_to_jd(year, month, 1)) + 1;
127    return new Array(year, month, day);
128}
129
130//تاریخ میلادی برمیگرداند
131function calcPersian(year, month, day) {
132    var date, j;
133    j = persian_to_jd(year, month, day);
134    date = jd_to_gregorian(j);
135    var weekday = jwday(j);
136    return new Array(date[0], date[1], date[2], weekday);
137}
138
139//  calcGregorian  --  Perform calculation starting with a Gregorian date
140//تاریخ شمسی را بر می گرداند
141function calcGregorian(year, month, day) {
142    month--;
143    var j, weekday;
144    //  Update Julian day
145    j = gregorian_to_jd(year, month + 1, day) +
146           (Math.floor(0 + 60 * (0 + 60 * 0) + 0.5) / 86400.0);
147    //  Update Persian Calendar
148    var perscal = jd_to_persian(j);
149    weekday = jwday(j);
150    return new Array(perscal[0], perscal[1], perscal[2], weekday);
151}
152
153function getTodayGregorian() {
154    var t = new Date();
155    var today = new Date();
156    var y = today.getYear();
157    if (y < 1000) {
158        y += 1900;
159    }
160    return new Array(y, today.getMonth() + 1, today.getDate(), t.getDay());
161}
162
163function GetTodayCalendarInPersian() {
164    var t = new Date();
165    var today = getTodayGregorian();
166    var persian = calcGregorian(today[0], today[1], today[2]);
167    return new Array(persian[0], persian[1], persian[2], t.getDay());
168}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.