Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dzucconi/calendrical
Fourmilab Calendar Converter as a library
https://github.com/dzucconi/calendrical
Last synced: 14 days ago
JSON representation
Fourmilab Calendar Converter as a library
- Host: GitHub
- URL: https://github.com/dzucconi/calendrical
- Owner: dzucconi
- Created: 2013-06-18T18:33:07.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T20:29:16.000Z (11 months ago)
- Last Synced: 2024-10-04T16:11:40.208Z (about 1 month ago)
- Language: JavaScript
- Homepage: http://dzucconi.github.io/calendrical/
- Size: 694 KB
- Stars: 13
- Watchers: 4
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Note:
This library is a more or less direct port of the [Fourmilab Calendar Converter](http://www.fourmilab.ch/documents/calendar/), just extracted from the DOM.
# Testing
A crude test suite is in place, consisting of basic [jasmine](http://jasmine.github.io/) test cases for the astro package and the Bahai calendar.
Currently it is not suitable for production usage. YMMV.
To run the test suite, you need node.js, npm and bower installed.
Then type the following:
```shell
bower install
npm install
```
Open the page test/index.html in your favourite web browser.Calendrical
===========[Fourmilab Calendar Converter](http://www.fourmilab.ch/documents/calendar/) as a library.
[Demo](http://dzucconi.github.com/calendrical/)
[Annotated](http://dzucconi.github.com/calendrical/docs/calendrical.calendar.base.html)Usage
-----```javascript
now = new Date();
// => Mon Jun 24 2013 17:24:03 GMT-0400 (EDT)Calendrical.calendar.updateTo(now);
// => Object {weekdayBefore: function, searchWeekday: function, nearestWeekday: function, nextWeekday: function, nextOrCurrentWeekday: function…}console.log(Calendrical.data);
// => Object {bahai: Object, excel_serial_1900: Object, excel_serial_1904: Object, french: Object, gregorian: Object…}
``````javascript
now = new Date();
// => Mon Jun 24 2013 17:24:03 GMT-0400 (EDT)now.getBahai();
// => Object {kull_i_shay: 1, vahid: 9, year: "Abhá", month: "Rahmat", day: "Jalál"…}now.getExcel1904();
// => Object {day: 39987.72503472213}now.getMayan();
// => Object {baktun: 13, katun: 0, tun: 0, uinal: 9, kin: 6…}Calendrical.astro.equationOfTime(now.getJulian());
// => 0.013450386503067681Calendrical.astro.sunpos(now.getJulian());
// => [93.03022447720286, 169.86108842444628, 0.016702965507475936, 0.33014519687687366, 93.36036967407973, 170.19123362132316, 1.0164516012170814, 93.35802029179253, 93.66176291046486, 23.394838008347406, 93.65915335631958, 23.39307037447384]
```