Hima 68401cb47c ff | 5 years ago | |
---|---|---|
.. | ||
.bower.json | 5 years ago | |
LICENSE | 5 years ago | |
README.md | 5 years ago | |
bower.json | 5 years ago | |
gulpfile.js | 5 years ago | |
hijrah-date.js | 5 years ago | |
hijrah-date.min.js | 5 years ago | |
hijrah-date.min.js.map | 5 years ago | |
karma.conf.js | 5 years ago | |
package.json | 5 years ago |
Javascript date in the Hijrah calendar system.
You can install this package either with npm
or with bower
.
npm install hijrah-date
bower install hijrah-date
Then add a <script>
to your index.html
:
<script src="/bower_components/hijrah-date/hijrah-date.js"></script>
new HijrahDate();
new HijrahDate(year, month[, day[, hour[, minutes[, seconds[, milliseconds]]]]]);
var hijrahDate1 = new HijrahDate();
var hijrahDate2 = new HijrahDate(1437, 11, 10);
var hijrahDate3 = new HijrahDate(1437, 11, 10, 14, 40);
Most of native Date
's read methods are available in HijrahDate
var hijrahDate = new HijrahDate(1437, 11, 14, 15, 50, 21, 456);
hijrahDate.getTime() // 1473943821456
hijrahDate.getFullYear() // 1437
hijrahDate.getMonth() // 11
hijrahDate.getDate() // 14
hijrahDate.getDay() // 4
hijrahDate.getHours() // 15
hijrahDate.getMinutes() // 50
hijrahDate.getSeconds() // 21
hijrahDate.getMilliseconds() // 456
hijrahDate.getMonthLength() // 30
hijrahDate.getYearLength() // 354
hijrahDate.getDayOfYear() // 338
hijrahDate.isLeapYear() // false
hijrahDate.toEpochDay() // 17055
HijrahDate::plusYears(yearsToAdd)
HijrahDate::plusMonths(monthsToAdd)
HijrahDate::plusWeeks(weeksToAdd)
HijrahDate::plusDays(daysToAdd)
HijrahDate::minusYears(yearsToSubtract)
HijrahDate::minusMonths(monthsToSubtract)
HijrahDate::minusWeeks(weeksToSubtract)
HijrahDate::minusDays(daysToSubtract)
Example
var hijrahDate = new HijrahDate(1437, 11, 10);
var hijrahDate2 = hd.plusYears(1)
.plusMonths(2)
.plusDays(5);
HijrahDate
To Date
Using HijrahDate::toGregorian
function
var hijrahDate = new HijrahDate(1437, 11, 10, 14, 40, 23, 15);
var date = hd.toGregorian();
Date
To HijrahDate
var date = new Date(2016, 9, 23);
var hijrahDate = new HijrahDate(date);
HijrahDate::format(format[, localeId])
Formats HijrahDate
to a string based on the requested format. Formats ported from AngularJS' date filter.
localeId
string 'en' or 'ar'
format
string can be composed of the following elements:
format string can also be one of the following predefined localizable formats:
format string can contain literal values. These need to be escaped by surrounding with single quotes (e.g. "h 'in the morning'"). In order to output a single quote, escape it - i.e., two single quotes in a sequence (e.g. "h 'o''clock'").