Buddhist Era plugin for Moment.js
- Buddhist Era (B.E.) support
Grab the file as well as moment.js. Then simply reference Moment Buddhist Era after Moment:
<script src="moment.min.js"></script>
<script src="moment-buddhist-era.js"></script>
If you want to pull from a CDN, this one is automatically kept up to date.
Add @chettapong/moment-buddhist-era.js
dependency to your project
yarn add --dev @chettapong/moment-buddhist-era.js # or npm install --save-dev @chettapong/moment-buddhist-era.js
// CommonJS
var moment = require('moment');
require('@chettapong/moment-buddhist-era.js');
// ESM
import moment from 'moment';
import '@chettapong/moment-buddhist-era.js';
Format
moment('2019-06-27T02:15:07+07:00').format('MM/DD/YYYY') // 06/27/2562
Disabled Buddhist Era
moment.buddhistEra(false)
moment('2019-06-27T02:15:07+07:00').format('MM/DD/YYYY') // 06/27/2019
Disabled Buddhist Era in format method
moment('2019-06-27T02:15:07+07:00').format('MM/DD/YYYY', { be: false }) // 06/27/2019
Add @chettapong/moment-buddhist-era.js
to the compilerOptions.types
section of your project's tsconfig.json
file:
{
"compilerOptions": {
"types": [
"@chettapong/moment-buddhist-era.js",
]
},
}
Copyright (c) 2021 Chettapong Pinsuwan