| 1 |
define([ |
| 2 |
"dojo/_base/lang", |
| 3 |
"dojo/_base/declare", |
| 4 |
"./numerals" |
| 5 |
], function(lang, declare, numerals){ |
| 6 |
|
| 7 |
var HDate = declare("dojox.date.hebrew.Date", null, { |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
_MONTH_LENGTH: [ |
| 52 |
|
| 53 |
[ 30, 30, 30 ], |
| 54 |
[ 29, 29, 30 ], |
| 55 |
[ 29, 30, 30 ], |
| 56 |
[ 29, 29, 29 ], |
| 57 |
[ 30, 30, 30 ], |
| 58 |
[ 30, 30, 30 ], |
| 59 |
[ 29, 29, 29 ], |
| 60 |
[ 30, 30, 30 ], |
| 61 |
[ 29, 29, 29 ], |
| 62 |
[ 30, 30, 30 ], |
| 63 |
[ 29, 29, 29 ], |
| 64 |
[ 30, 30, 30 ], |
| 65 |
[ 29, 29, 29 ] |
| 66 |
], |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
_MONTH_START: [ |
| 74 |
|
| 75 |
[ 0, 0, 0 ], |
| 76 |
[ 30, 30, 30 ], |
| 77 |
[ 59, 59, 60 ], |
| 78 |
[ 88, 89, 90 ], |
| 79 |
[ 117, 118, 119 ], |
| 80 |
[ 147, 148, 149 ], |
| 81 |
[ 147, 148, 149 ], |
| 82 |
[ 176, 177, 178 ], |
| 83 |
[ 206, 207, 208 ], |
| 84 |
[ 235, 236, 237 ], |
| 85 |
[ 265, 266, 267 ], |
| 86 |
[ 294, 295, 296 ], |
| 87 |
[ 324, 325, 326 ], |
| 88 |
[ 353, 354, 355 ] |
| 89 |
], |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
_LEAP_MONTH_START: [ |
| 95 |
|
| 96 |
[ 0, 0, 0 ], |
| 97 |
[ 30, 30, 30 ], |
| 98 |
[ 59, 59, 60 ], |
| 99 |
[ 88, 89, 90 ], |
| 100 |
[ 117, 118, 119 ], |
| 101 |
[ 147, 148, 149 ], |
| 102 |
[ 177, 178, 179 ], |
| 103 |
[ 206, 207, 208 ], |
| 104 |
[ 236, 237, 238 ], |
| 105 |
[ 265, 266, 267 ], |
| 106 |
[ 295, 296, 297 ], |
| 107 |
[ 324, 325, 326 ], |
| 108 |
[ 354, 355, 356 ], |
| 109 |
[ 383, 384, 385 ] |
| 110 |
], |
| 111 |
|
| 112 |
_GREGORIAN_MONTH_COUNT: [ |
| 113 |
|
| 114 |
[ 31, 31, 0, 0 ], |
| 115 |
[ 28, 29, 31, 31 ], |
| 116 |
[ 31, 31, 59, 60 ], |
| 117 |
[ 30, 30, 90, 91 ], |
| 118 |
[ 31, 31, 120, 121 ], |
| 119 |
[ 30, 30, 151, 152 ], |
| 120 |
[ 31, 31, 181, 182 ], |
| 121 |
[ 31, 31, 212, 213 ], |
| 122 |
[ 30, 30, 243, 244 ], |
| 123 |
[ 31, 31, 273, 274 ], |
| 124 |
[ 30, 30, 304, 305 ], |
| 125 |
[ 31, 31, 334, 335 ] |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
], |
| 131 |
|
| 132 |
_date: 0, |
| 133 |
_month: 0, |
| 134 |
_year: 0, |
| 135 |
_hours: 0, |
| 136 |
_minutes: 0, |
| 137 |
_seconds: 0, |
| 138 |
_milliseconds: 0, |
| 139 |
_day: 0, |
| 140 |
|
| 141 |
constructor: function(){ |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
var len = arguments.length; |
| 150 |
if(!len){ |
| 151 |
this.fromGregorian(new Date()); |
| 152 |
}else if(len == 1){ |
| 153 |
var arg0 = arguments[0]; |
| 154 |
if(typeof arg0 == "number"){ |
| 155 |
arg0 = new Date(arg0); |
| 156 |
} |
| 157 |
|
| 158 |
if(arg0 instanceof Date){ |
| 159 |
this.fromGregorian(arg0); |
| 160 |
}else if(arg0 == ""){ |
| 161 |
|
| 162 |
this._year = this._month = this._date = this._hours = this._minutes = this._seconds = this._milliseconds = NaN; |
| 163 |
}else{ |
| 164 |
this._year = arg0._year; |
| 165 |
this._month = arg0._month; |
| 166 |
this._date = arg0._date; |
| 167 |
this._hours = arg0._hours; |
| 168 |
this._minutes = arg0._minutes; |
| 169 |
this._seconds = arg0._seconds; |
| 170 |
this._milliseconds = arg0._milliseconds; |
| 171 |
} |
| 172 |
}else if(len >= 3){ |
| 173 |
|
| 174 |
this._year += arguments[0]; |
| 175 |
this._month += arguments[1]; |
| 176 |
this._date += arguments[2]; |
| 177 |
|
| 178 |
if(this._month > 12){ |
| 179 |
console.warn("the month is incorrect , set 0 " + this._month + " " + this._year ); |
| 180 |
this._month = 0; |
| 181 |
} |
| 182 |
this._hours += arguments[3] || 0; |
| 183 |
this._minutes += arguments[4] || 0; |
| 184 |
this._seconds += arguments[5] || 0; |
| 185 |
this._milliseconds += arguments[6] || 0; |
| 186 |
} |
| 187 |
|
| 188 |
this._setDay(); |
| 189 |
}, |
| 190 |
|
| 191 |
getDate: function(){ |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
return this._date; |
| 199 |
}, |
| 200 |
|
| 201 |
getDateLocalized: function(locale){ |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
return (locale || dojo.locale).match(/^he(?:-.+)?$/) ? |
| 210 |
numerals.getDayHebrewLetters(this._date) : this.getDate(); |
| 211 |
}, |
| 212 |
|
| 213 |
getMonth: function(){ |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
return this._month; |
| 242 |
}, |
| 243 |
|
| 244 |
getFullYear: function(){ |
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
return this._year; |
| 252 |
}, |
| 253 |
|
| 254 |
getHours: function(){ |
| 255 |
|
| 256 |
|
| 257 |
return this._hours; |
| 258 |
}, |
| 259 |
|
| 260 |
getMinutes: function(){ |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
return this._minutes; |
| 265 |
}, |
| 266 |
|
| 267 |
getSeconds: function(){ |
| 268 |
|
| 269 |
|
| 270 |
return this._seconds; |
| 271 |
}, |
| 272 |
|
| 273 |
getMilliseconds: function(){ |
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
return this._milliseconds; |
| 278 |
}, |
| 279 |
|
| 280 |
setDate: function(date){ |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
date = +date; |
| 288 |
var mdays; |
| 289 |
if(date>0){ |
| 290 |
while (date > (mdays = this.getDaysInHebrewMonth(this._month, this._year))){ |
| 291 |
date -= mdays; |
| 292 |
this._month++; |
| 293 |
if(this._month >= 13){this._year++; this._month -= 13;} |
| 294 |
} |
| 295 |
}else{ |
| 296 |
while(date<=0){ |
| 297 |
mdays = this.getDaysInHebrewMonth((this._month-1)>=0 ? (this._month-1) : 12, ((this._month-1)>=0)? this._year : this._year-1); |
| 298 |
this._month--; |
| 299 |
if(this._month < 0){this._year--; this._month += 13;} |
| 300 |
date += mdays; |
| 301 |
} |
| 302 |
} |
| 303 |
this._date = date; |
| 304 |
this._setDay(); |
| 305 |
return this; |
| 306 |
}, |
| 307 |
|
| 308 |
|
| 309 |
setFullYear: function(year, month, date){ |
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
this._year = year = +year; |
| 318 |
if(!this.isLeapYear(year) && this._month==5){ |
| 319 |
this._month++; |
| 320 |
} |
| 321 |
|
| 322 |
if(month !== undefined){this.setMonth(month);} |
| 323 |
if(date !== undefined){this.setDate(date);} |
| 324 |
|
| 325 |
var dnum = this.getDaysInHebrewMonth(this._month, this._year); |
| 326 |
if(dnum < this._date){ |
| 327 |
this._date = dnum; |
| 328 |
} |
| 329 |
|
| 330 |
this._setDay(); |
| 331 |
return this; |
| 332 |
}, |
| 333 |
|
| 334 |
setMonth: function(month){ |
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
month = +month; |
| 360 |
if(!this.isLeapYear(this._year) && month == 5){month++;} |
| 361 |
|
| 362 |
if(month>=0){ |
| 363 |
while(month >12){ |
| 364 |
this._year++; |
| 365 |
month -= 13; |
| 366 |
if (!this.isLeapYear(this._year) && month >= 5){month++;} |
| 367 |
} |
| 368 |
}else{ |
| 369 |
while(month<0){ |
| 370 |
this._year--; |
| 371 |
month += (!this.isLeapYear(this._year) && month < -7) ? 12 : 13; |
| 372 |
} |
| 373 |
} |
| 374 |
|
| 375 |
this._month = month; |
| 376 |
|
| 377 |
var dnum = this.getDaysInHebrewMonth(this._month, this._year); |
| 378 |
if(dnum < this._date){ |
| 379 |
this._date = dnum; |
| 380 |
} |
| 381 |
|
| 382 |
this._setDay(); |
| 383 |
return this; |
| 384 |
}, |
| 385 |
|
| 386 |
setHours: function(){ |
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
var hours_arg_no = arguments.length; |
| 396 |
var hours = 0; |
| 397 |
if(hours_arg_no >= 1){ |
| 398 |
hours = +arguments[0]; |
| 399 |
} |
| 400 |
|
| 401 |
if(hours_arg_no >= 2){ |
| 402 |
this._minutes = +arguments[1]; |
| 403 |
} |
| 404 |
|
| 405 |
if(hours_arg_no >= 3){ |
| 406 |
this._seconds = +arguments[2]; |
| 407 |
} |
| 408 |
|
| 409 |
if(hours_arg_no == 4){ |
| 410 |
this._milliseconds = +arguments[3]; |
| 411 |
} |
| 412 |
|
| 413 |
while(hours >= 24){ |
| 414 |
this._date++; |
| 415 |
var mdays = this.getDaysInHebrewMonth(this._month, this._year); |
| 416 |
if(this._date > mdays) |
| 417 |
{ |
| 418 |
this._month++; |
| 419 |
if(!this.isLeapYear(this._year) && this._month==5){ this._month++; } |
| 420 |
if(this._month >= 13){this._year++; this._month -= 13;} |
| 421 |
this._date -= mdays; |
| 422 |
} |
| 423 |
hours -= 24; |
| 424 |
} |
| 425 |
this._hours = hours; |
| 426 |
this._setDay(); |
| 427 |
return this; |
| 428 |
}, |
| 429 |
|
| 430 |
_addMinutes: function(minutes){ |
| 431 |
minutes += this._minutes; |
| 432 |
this.setMinutes(minutes); |
| 433 |
this.setHours(this._hours + parseInt(minutes / 60)); |
| 434 |
return this; |
| 435 |
}, |
| 436 |
|
| 437 |
_addSeconds: function(seconds){ |
| 438 |
seconds += this._seconds; |
| 439 |
this.setSeconds(seconds); |
| 440 |
this._addMinutes(parseInt(seconds / 60)); |
| 441 |
return this; |
| 442 |
}, |
| 443 |
|
| 444 |
_addMilliseconds: function(milliseconds){ |
| 445 |
milliseconds += this._milliseconds; |
| 446 |
this.setMilliseconds(milliseconds); |
| 447 |
this._addSeconds(parseInt(milliseconds / 1000)); |
| 448 |
return this; |
| 449 |
}, |
| 450 |
|
| 451 |
setMinutes: function(minutes){ |
| 452 |
|
| 453 |
|
| 454 |
this._minutes = minutes % 60; |
| 455 |
return this; |
| 456 |
}, |
| 457 |
|
| 458 |
setSeconds: function(seconds){ |
| 459 |
|
| 460 |
|
| 461 |
this._seconds = seconds % 60; |
| 462 |
return this; |
| 463 |
}, |
| 464 |
|
| 465 |
setMilliseconds: function(milliseconds){ |
| 466 |
this._milliseconds = milliseconds % 1000; |
| 467 |
return this; |
| 468 |
}, |
| 469 |
|
| 470 |
_setDay: function(){ |
| 471 |
var day = this._startOfYear(this._year); |
| 472 |
if(this._month != 0){ |
| 473 |
day += (this.isLeapYear(this._year) ? this._LEAP_MONTH_START : this._MONTH_START)[this._month || 0][this._yearType(this._year)]; |
| 474 |
} |
| 475 |
day += this._date - 1; |
| 476 |
this._day = (day+1) % 7; |
| 477 |
}, |
| 478 |
|
| 479 |
toString: function(){ |
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
return isNaN(this._date)?"Invalid Date": |
| 492 |
this._date + ", " + this._month + ", " + this._year + " " + this._hours + ":" + this._minutes + ":" + this._seconds; |
| 493 |
}, |
| 494 |
|
| 495 |
|
| 496 |
getDaysInHebrewMonth: function(month, year){ |
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
var yearType = (month == 1 || month == 2) ? this._yearType(year) : 0; |
| 503 |
return (!this.isLeapYear(this._year) && month == 5) ? 0 : this._MONTH_LENGTH[month][yearType]; |
| 504 |
}, |
| 505 |
|
| 506 |
|
| 507 |
_yearType: function(year){ |
| 508 |
var yearLength = this._handleGetYearLength(Number(year)); |
| 509 |
if(yearLength > 380){ |
| 510 |
yearLength -= 30; |
| 511 |
} |
| 512 |
|
| 513 |
var yearType = yearLength - 353; |
| 514 |
if (yearType < 0 || yearType > 2){ |
| 515 |
throw new Error("Illegal year length " + yearLength + " in year " + year); |
| 516 |
} |
| 517 |
return yearType; |
| 518 |
}, |
| 519 |
|
| 520 |
|
| 521 |
_handleGetYearLength: function(eyear){ |
| 522 |
return this._startOfYear(eyear+1) - this._startOfYear(eyear); |
| 523 |
}, |
| 524 |
|
| 525 |
|
| 526 |
_startOfYear: function(year){ |
| 527 |
var months = Math.floor((235 * year - 234) / 19), |
| 528 |
frac = months * (12*1080 + 793) + 11*1080 + 204, |
| 529 |
day = months * 29 + Math.floor(frac / (24*1080)); |
| 530 |
frac %= 24*1080; |
| 531 |
|
| 532 |
var wd = day % 7; |
| 533 |
|
| 534 |
if(wd == 2 || wd == 4 || wd == 6){ |
| 535 |
|
| 536 |
day += 1; |
| 537 |
wd = day % 7; |
| 538 |
} |
| 539 |
if(wd == 1 && frac > 15 * 1080 + 204 && !this.isLeapYear(year)){ |
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
day += 2; |
| 544 |
}else if(wd == 0 && frac > 21 * 1080 + 589 && this.isLeapYear(year-1)){ |
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
day += 1; |
| 549 |
} |
| 550 |
|
| 551 |
return day; |
| 552 |
}, |
| 553 |
|
| 554 |
|
| 555 |
isLeapYear: function(year){ |
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
var x = (year*12 + 17) % 19; |
| 563 |
return x >= ((x < 0) ? -7 : 12); |
| 564 |
}, |
| 565 |
|
| 566 |
|
| 567 |
fromGregorian: function(gdate){ |
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
var result = (!isNaN(gdate)) ? this._computeHebrewFields(gdate) : NaN; |
| 576 |
this._year = (!isNaN(gdate)) ? result[0] : NaN; |
| 577 |
this._month = (!isNaN(gdate))? result[1] : NaN; |
| 578 |
this._date = (!isNaN(gdate)) ? result[2] : NaN; |
| 579 |
this._hours = gdate.getHours(); |
| 580 |
this._milliseconds = gdate.getMilliseconds(); |
| 581 |
this._minutes = gdate.getMinutes(); |
| 582 |
this._seconds = gdate.getSeconds(); |
| 583 |
if (!isNaN(gdate)) this._setDay(); |
| 584 |
return this; |
| 585 |
}, |
| 586 |
|
| 587 |
|
| 588 |
_computeHebrewFields: function(gdate){ |
| 589 |
var julianDay = this._getJulianDayFromGregorianDate(gdate), |
| 590 |
d = julianDay - 347997, |
| 591 |
m = Math.floor((d * 24*1080) / (29*24*1080 + 12*1080 + 793)), |
| 592 |
year = Math.floor((19 * m + 234) / 235) + 1, |
| 593 |
ys = this._startOfYear(year), |
| 594 |
dayOfYear = (d - ys); |
| 595 |
|
| 596 |
while(dayOfYear < 1){ |
| 597 |
year--; |
| 598 |
ys = this._startOfYear(year); |
| 599 |
dayOfYear = d - ys; |
| 600 |
} |
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
var typeofYear = this._yearType(year), |
| 605 |
monthStart = this.isLeapYear(year) ? this._LEAP_MONTH_START : this._MONTH_START, |
| 606 |
month = 0; |
| 607 |
|
| 608 |
while(dayOfYear > monthStart[month][typeofYear]){ |
| 609 |
month++; |
| 610 |
} |
| 611 |
month--; |
| 612 |
var dayOfMonth = dayOfYear - monthStart[month][typeofYear]; |
| 613 |
return [year, month, dayOfMonth]; |
| 614 |
}, |
| 615 |
|
| 616 |
|
| 617 |
toGregorian: function(){ |
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
var hYear = this._year || 0, |
| 625 |
hMonth = this._month || 0, |
| 626 |
hDate = this._date || 0, |
| 627 |
day = this._startOfYear(hYear); |
| 628 |
|
| 629 |
if(hMonth != 0){ |
| 630 |
day += (this.isLeapYear(hYear) ? this._LEAP_MONTH_START : this._MONTH_START)[hMonth][this._yearType(hYear)]; |
| 631 |
} |
| 632 |
|
| 633 |
var julianDay = (hDate + day + 347997), |
| 634 |
|
| 635 |
gregorianEpochDay = julianDay - 1721426; |
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
var rem = []; |
| 642 |
var n400 = this._floorDivide(gregorianEpochDay , 146097, rem), |
| 643 |
n100 = this._floorDivide(rem[0] , 36524, rem), |
| 644 |
n4 = this._floorDivide(rem[0] , 1461, rem), |
| 645 |
n1 = this._floorDivide(rem[0] , 365, rem), |
| 646 |
year = 400*n400 + 100*n100 + 4*n4 + n1, |
| 647 |
dayOfYear = rem[0]; |
| 648 |
|
| 649 |
if(n100 == 4 || n1 == 4){ |
| 650 |
dayOfYear = 365; |
| 651 |
}else{ |
| 652 |
++year; |
| 653 |
} |
| 654 |
|
| 655 |
var isLeap = !(year%4) && |
| 656 |
(year%100 || !(year%400)), |
| 657 |
correction = 0, |
| 658 |
march1 = isLeap ? 60 : 59; |
| 659 |
if(dayOfYear >= march1){ correction = isLeap ? 1 : 2; } |
| 660 |
var month = Math.floor((12 * (dayOfYear + correction) + 6) / 367); |
| 661 |
var dayOfMonth = dayOfYear - |
| 662 |
this._GREGORIAN_MONTH_COUNT[month][isLeap ? 3 : 2] + 1; |
| 663 |
|
| 664 |
return new Date(year, month, dayOfMonth, this._hours, this._minutes, this._seconds, this._milliseconds); |
| 665 |
}, |
| 666 |
_floorDivide: function(numerator, denominator, remainder){ |
| 667 |
if(numerator >= 0){ |
| 668 |
remainder[0] = (numerator % denominator); |
| 669 |
return Math.floor(numerator / denominator); |
| 670 |
} |
| 671 |
var quotient = Math.floor(numerator / denominator); |
| 672 |
remainder[0] = numerator - (quotient * denominator); |
| 673 |
return quotient; |
| 674 |
}, |
| 675 |
|
| 676 |
getDay: function(){ |
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
var hYear = this._year, |
| 684 |
hMonth = this._month, |
| 685 |
hDate = this._date, |
| 686 |
day = this._startOfYear(hYear); |
| 687 |
|
| 688 |
if(hMonth != 0){ |
| 689 |
day += (this.isLeapYear(hYear) ? this._LEAP_MONTH_START : this._MONTH_START)[hMonth][this._yearType(hYear)]; |
| 690 |
} |
| 691 |
|
| 692 |
day += hDate - 1; |
| 693 |
return (day+1) % 7; |
| 694 |
}, |
| 695 |
|
| 696 |
|
| 697 |
_getJulianDayFromGregorianDate: function(gdate){ |
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
var year = gdate.getFullYear(), |
| 702 |
month = gdate.getMonth(), |
| 703 |
d = gdate.getDate(), |
| 704 |
isLeap = !(year%4) && (year%100 || !(year%400)), |
| 705 |
y = year - 1; |
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
var julianDay = 365*y + Math.floor(y/4) - Math.floor(y/100) + |
| 710 |
Math.floor(y/400) + 1721426 - 1; |
| 711 |
|
| 712 |
|
| 713 |
if(month > 0) { |
| 714 |
julianDay += this._GREGORIAN_MONTH_COUNT[month][isLeap ? 3 : 2]; |
| 715 |
} |
| 716 |
|
| 717 |
julianDay += d; |
| 718 |
return julianDay; |
| 719 |
} |
| 720 |
}); |
| 721 |
|
| 722 |
HDate.prototype.valueOf = function(){ |
| 723 |
return this.toGregorian().valueOf(); |
| 724 |
}; |
| 725 |
return HDate; |
| 726 |
}); |