moment-ethiopia
v0.1.1
Published
An Ethiopian calendar plugin for moment.js.
Downloads
203
Maintainers
Readme
moment-ethiopia
An Ethiopian calendar system plugin for moment.js.
About
The Ethiopian calendar (also called the Ge'ez calendar) is the principal calendar used in Ethiopia and Eritrea. It is based on the older Alexandrian or Coptic calendar, which in turn derives from the Egyptian calendar. More information about the Ethiopian calendar can be found at wikipedia.
This plugin adds Ethiopian calendar support to momentjs library.
Where to use it?
Like momentjs, moment-ethiopia works in browser and in Node.js.
Node.js
npm install moment-ethiopiavar moment = require('moment-ethiopia');
moment().format('eYYYY/eM/eD');Browser
<script src="moment.js"></script>
<script src="moment-ethiopia.js"></script>
<script>
moment().format('eYYYY/eM/eD');
</script>Require.js
require.config({
paths: {
"moment": "path/to/moment",
"moment-ethiopia": "path/to/moment-ethiopia"
}
});
define(["moment-ethiopia"], function (moment) {
moment().format('eYYYY/eM/eD');
});API
This plugin tries to mimic momentjs api. Basically, when formatting or parsing a string, add an e to the format token such as 'eYYYY' or 'eM'. For example:
// TODO: Add example usage once implementation is complete
m = moment('2007/3/19', 'eYYYY/eM/eD'); // Parse an Ethiopian date.
m.format('eYYYY/eM/eD [is] YYYY/M/D'); // 2007/3/19 is 2014/11/28
m.eYear(); // 2007
m.eMonth(); // 2 (0-indexed, so 3rd month)
m.eDate(); // 19
m.eDayOfYear(); // 79
m.eWeek(); // 12
m.eWeekYear(); // 2007
m.add(1, 'eYear');
m.add(2, 'eMonth');
m.add(1, 'edate');
m.format('eYYYY/eM/eD'); // 2008/5/20
m.eMonth(11);
m.startOf('eMonth');
m.format('eYYYY/eM/eD'); // 2008/12/1
m.eYear(2014);
m.startOf('eYear');
m.format('eYYYY/eM/eD'); // 2014/1/1To use the Amharic locale:
- Load moment-with-locales.
- Set the global or local locale to
am-ETsee here. - use it normally :+1:
Here is example:
<!-- 1- Load the moment-with-locales -->
<script src="http://momentjs.com/downloads/moment-with-locales.min.js"></script>
<script src="https://raw.githubusercontent.com/supershutong/moment-ethiopia/master/index.js"></script>
<script>
moment.locale('am-ET');// 2- Set the global locale to `am`
m = moment();
m.format('eYYYY/eM/eD'); //3- use it normally
</script>Acknowledgements
This project was built from the great work done by @xsoh whose behind moment-hijri project, which in turn was inspired by moment-jalaali by @behrang.
License
MIT
