Package Exports
- @thyrith/momentkh
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 (@thyrith/momentkh) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
momentkh
momentkh is an add-on feature to moment js library
Install π
$ npm install moment --save
$ npm install @thyrith/momentkh --saveHow to use π«
This library is built depends on moment.js popular library. We added some functionality to make it easier to work with Khmer date format.
const moment = require('moment');
// Add our features to your preferred moment.js version
require('@thyrith/momentkh')(moment);
// From now on, your moment js is transformed
let today = moment();
console.log(today);
// Display date today as moment js object
// For example: moment("2018-12-15T14:49:38.586")
let khmerDate = today.toLunarDate();
console.log(khmerDate);
// Display khmer date
// For example: αααααα
αα α¨ααΎα αααα·ααα·α ααααΆαα
ααααΉαααααα αα»αααααααΆα α’α₯α¦α’Added Functionality π‘
Attributes of moment instance
| Name | Parameter | Description | Example |
|---|---|---|---|
| toLunarDate | empty or String | display format as Khmer lunar date | moment().toLunarDate(); |
| khDay | empty | display khmer day index | moment().khDay(); 0 -> α‘ααΎα 1 -> α’ααΎα 2 -> α£ααΎα ... 15 -> α‘ααα 16 -> α’ααα 17 -> α£ααα ... |
| khMonth | empty | display khmer month index | moment.khMonth(); 0 -> αα·ααα·α 1 -> αα»ααα 2 -> ααΆα 3 -> ααααα»α 4 -> α αααα 5 -> αα·ααΆα 6 -> ααααα 7 -> α’αΆααΆα 8 -> ααααΆααα 9 -> αααααα 10 -> α’αααα»α 11 -> ααααα·α 12 -> ααααΆααΆα 13 -> αα»αα·ααΆααΆα |
| khYear | empty | display Buddhist Era year | moment().khYear(); |
Alias
| Name | Original |
|---|---|
| toKhDate, tokhdate | toLunarDate |
Attributes of moment
| Name | Parameter | Description | Example |
|---|---|---|---|
| getKhNewYearMoment | Integer | Return moment.js object. Giving the moment of Khmer New Year. (ααααααααΆα α»α) | moment.getKhNewYearMoment(2019); |
| String or Object | Return moment.js object. Just same as calling: moment('13/04/2018', 'dd/mm/yyyy'); for Gregorian date |
moment.readLunarDate('α‘α₯ααΎα αα·ααΆα α.α. α’α₯α₯α₯'); |
Alias
| Name | Original |
|---|---|
| khDate, khdate | readLunarDate |
Format
By default, it will return the format as shown in example above. However, you can also customize your format.
// Use moment.js as usual. Documentaion: momentjs.com
let myBirthday = moment('4/3/1992', 'd/m/yyy');
myBirthday.toLunarDate('dN ααααW ααm α.α. b');
// α¦ααΎα αααααααα ααααα·α αααα·ααα·α α.α. α’α₯α¦α’'| Format | Description | Example |
|---|---|---|
| W | αααααααααααΆα α | α’ααααΆα |
| w | αααααααααααΆα αααΆαα | α’ |
| d | ααααααΈ α αΆααααΈααα α‘ ααα α‘α₯ | α‘ |
| D | ααααααΈ α αΆααααΈααα α α‘ ααα α‘α₯ | α α‘ |
| n | ααΎα α¬ ααα | α |
| N | ααΎα α¬ ααα | ααΎα |
| o | αααααααααααααΈα’αααΈααααααΈ | α§‘ (ααΆααααααΆ α‘ααΎα) |
| m | αα | αα·ααα·α β |
| a | ααααΆααααα | αααΆ |
| e | ααα | α―αααα |
| b | ααααΆααα»αααααααΆα | α’α₯α₯α¦ |
| c | ααααΆααααα·αααααααΆα | α’α α‘α© |
| j | ααααΆαα α»αααααααΆα | α‘α€α¦α£ |
Bug Report πππ¦π·πΈπ¦π¦πππ£
I know there will be a lot of error.
Testing
There is no test running on this package. If you are available for this work, it would be very awesome.
Contribute π‘
Welcome pull request
References
Support me
I'm really happy if this project is useful to you.
If you would like to buy me some breakfast, here is my ABA account number: 000 485 222. Don't forget to remark momentkh so that I can count it as usefulness of my work.