Package Exports
- romcal
- romcal/package.json
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (romcal) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Romcal
Generates the General Roman Calendar used in the Catholic Rite.
Description
Romcal is a module that generates the General Roman Calendar used in the Roman Catholic Rite. This module conforms to the revised liturgical calendar for the Western Church as approved by Paul VI in Mysterii Paschalis dated 14 February 1969. This module will output dates based on the standard calendar year (Jan, 1st - Dec, 31st) even though the liturgical year begins with the First Sunday of Advent.
Features
- Able to query liturgical dates for any year in the gregorian calendar (1582 - now). Note that dates for years before 1969 will still be returned in a format conforming to Mysterii Paschalis even though those years came before the calendar reforms in 1969.
- 31 filter queries to allow more strealined date results to be obtained for the year
- Localization of liturgical date names to cater for different countries/languages
- National liturgical calendars of 41 countries
NOTE:This module relies heavily on Moment and Lo-Dash (which are dependencies of this module) for most of its calculations and operations. Twix is also extensively used for creating and manipulating date ranges.
Module Robustness & Data Integrity
Calendar entries for this module are pulled from various sources from the net. As such their accuracy cannot be ensured. If you find an incorrect calendar entry (e.g. wrong date, wrong feast type, spelling issue, typos), you are most welcome to contribute to the source code or inform me so that the necessary changes can be made to make this a more robust and reliable app
Romcal's code logic is developed according to calendar requirements descibed in various church documents sourced from the internet (and even from Wikipedia). If you notice discrepancies between romcal's output and actual dates, please do contribute your fixes or submit an issue on GitHub.
Revisions
- 1.0.7 Fix type errors in other celebrations
- 1.0.6 Fix filesystem error when attempting to load localization.json
- 1.0.5 Liturgical Cycles + Bug Fixes + Proper error handling conventions for
calendarFor()method - 1.0.4 Bug fixes for National Calendars
- 1.0.3 National calendars [beta] and a new localization mechanism
- 1.0.2 Fix incorrect moment dependency version and added holyWeek query
- 1.0.1 Added more TDD tests
- 1.0.0 Initial release
Usage
Add romcal to your project via npm:
$ npm install romcalThen require romcal in your node project:
var romcal = require('romcal');Get an array of liturgical dates for a year by calling the calendarFor() method.
The method accepts 2 optional parameters and 1 mandatory parameter:
yearoptional The Gregorian year as a string. Defaults to current year if nulllocaleoptional The locale (e.g. en-US, en-GB, fr-FR). Defaults to en-US if nullcbmandatory The callback function with the following parameters:errAn error object if an error occured, null if there is no errordatesAn array of liturgical dates
Note: At the moment, romcal only contains localized values for the en-US locale. Passing in any other locale will return en-US texts until those locales are localized.
romcal.calendarFor( function( err, dates ) {
console.log( dates );
});
romcal.calendarFor('2014', function( err, dates ) {
console.log( dates );
});
romcal.calendarFor('2014', 'en-US', function( err, dates ) {
console.log( dates );
});Each item in the array returned is an object literal that contains:
- A moment object definition for the liturgical date (all dates returned in UTC)
- The type of liturgical date (e.g. Solemnity, Memorial, Sunday, Weekday .. )
- The name of the liturgical date (localizable)
- Additional data pertaining to the liturgical date (e.g. liturgical season )
Query API
romcal also provides additional queries that can be used to streamline the original date output via the queryFor() method. For examples on usage of this method, check out the TDD scripts in romcal's test folder.
romcal.queryFor('mondays', dates, function( err, query ) {
console.log( query );
});The method accepts 2 parameters:
querymandatory The query type to perform (see below)datesmandatory An array of dates returned bycalendarFor()or a single date item when theliturgicalCyclequery is usedcallbackmandatory The callback function with 2 parameters:errA JSON object describing the error (if any). null if there are no errorsqueryThe filtered liturgical dates will be returned
Query for liturgical cycle
liturgicalCycle- Returns the liturgical cycle for the given date. A liturgical cycle starts on the first Sunday of Advent and ends on the Feast of Christ the King (last Sunday of Ordinary Time).
Queries for date ranges
ordinaryTime- Returns an array of dates in the season of Ordinary Time (Day after Baptism of the Lord till day before Ash Wednesday & dat after Pentecost to Christ the King)
lent- Returns an array of dates corresponding to the season of Lent (Ash Wednesday up to the day beforee Palm Sunday)
holyWeek- Returns an array of dates from Palm Sunday to Easter Vigil
easter- Returns an array of dates corresponding to the season of Easter (Easter Sunday up to Pentecost)
advent- Returns an array of dates in the season of Advent ( 1st Sunday of Advent to Christmas Eve)
christmastide- Returns an array of dates from Christmas day to Epiphany
Queries for specific liturgical date types
feastsOfTheLord- An array of dates for Baptism of the Lord, Presentation of the Lord, Transfiguration, Triumph of the Cross and Holy Family
memorials- An array of memorials throughout the liturgical year conforming to the General Roman Calendar. It does not include memorials from National, Diocesan or Parish level calendars.
optionalMemorials- An array of optional memorials throughout the liturgical year conforming to the General Roman Calendar. It does not include memorials from National, Diocesan or Parish level calendars.
commemoration- An array of downgraded memorials/optional memorials that occur only during the season of Lent
solemnities- Returns an array of the highest ranking feast days throughout the liturgical year
Other queries to return days or months
sundaysmondaystuesdayswednesdaysthursdaysfridayssaturdaysdaysGrouped- Returns all dates in the year grouped by day
liturgicalYear- Returns the current liturgical cycle for the date given (e.g Cycle A, B or C)
januaryfebruarymarchaprilmayjunejulyaugustseptemberoctobernovemberdecember
National Calendars [Beta]
Romcal is able to display the national calendars (specific liturgical dates of a country) for 41 countries.
To query a national calendar, use the queryNationalCalendar() method.
queryNationalCalendar() is much more rigid than the standard calendarFor() method. All parameters are mandatory and romcal will return null or throw an error if any of these parameters are not satisfied. The parameters in order are:
yearmandatory The year of liturgical dates to be obtainedlocalemandatory The locale (e.g. en-US, en-GB, fr-FR)countrymandatory The country of which the national calendar is to be obtained. Possible values for this parameter are:argentinaaustraliabelgiumboliviabosniaHerzegovinabrazilcanadachilecroatiaczechRepublicenglandfrancefinlandgermanygreecehungaryindiairelandjapanlebanonlithuaniamaltamexiconewZealandnorwayperuphilippinespolandportugalpuertoRicoromaniarussiascotlandslovakiaspainsriLankaukraineunitedStatesvietnamwales
callbackmandatory The callback function with 2 parameters:errAn error object if any errors occured. null if no errorsresultAn array of dates for the National Liturgical year of the country
Adding National Calendars
- National Calendars can be added to romcal by editing the
calendars()function inlib/utils.js. This function returns an object literal containing attributes of the General calendar as well as National Calendars. New countries can be added on by referring to the format of this object literal. - The next file to edit is
lib/nationalCalendar.js. The country and the specific celebrations as defined in its National Calendar (as determined by the council of Bishops and approved by the Holy See) is added to thedates()function. Ensure that the newly added country conforms to the defined object literal structure. - Finally, create localizable entries for celebrations of the country's national calendar via
data/localization.json
Localization
- Display names for liturgical dates in romcal are localizable.
- romcal can potentially support an unlimited number of language-locales
data/localization.jsonis a data file in JSON format that holds all localized liturgical date names.- As of this release, romcal only contains valid localizable values for en-US. Eagerly looking forward to contributions to help localize the other languages!
- Contributing localizations for romcal is easy:
- Open up
data/localization.jsonin your favourite JSON Editor (e.g JSON Editor Online ) - Enter localized text for an item (e.g.
ourLadyMediatrix) based on its locale code (e.gen-GB) - Save and submit the updated
data/localization.jsonfile
- Open up
Roadmap
- Better testing scripts (I am still quite new to Mocha, Should etc)
- Psalter weeks
- More localization values for locales
- More queries
If you have any suggestions for improvement, feel free to contribute to this exciting project!
Acknowledgements
The development of romcal is inspired by the work of Kenneth G, Bath who wrote a General Roman Calendar in the C language. This module is not a port of the C program and does not use any of the C code in that program. This module is written from scratch with the aim of provide similar output as the original C program while providing additional queries for convenient filtering/streamlining of date results.
License
romcal is freely distributable under the terms of the MIT license.