npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@thyrith/momentkh

v2.5.5

Published

Working on khmer calendar by implementting moment js

Downloads

1,134

Readme

NPM version GitHub issues GitHub forks GitHub stars GitHub license

momentkh

momentkh is an add-on feature to moment js library DEMO.

Install 🗜

$ npm install moment --save
$ npm install @thyrith/momentkh --save

How 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.

Nodejs

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: ថ្ងៃសៅរ៍ ៨កើត ខែមិគសិរ ឆ្នាំច សំរឹទ្ធស័ក ពុទ្ធសករាជ ២៥៦២

HTML

First, you need to clone this package to the root of your project or your /public folder.

*** For momentjs library, you can import it any method or any version you want.

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src="momentkh/constant.js"></script>
<script src="momentkh/locale/km.js"></script>
<script src="momentkh/getSoriyatraLerngSak.js"></script>
<script src="momentkh/momentkh.js"></script>
<script>
	var moment = momentkh(moment)
	var today = moment()
	console.log('Today: ', today.toKhDate())
	console.log('New year at: ', moment.getKhNewYearMoment(2021))
</script>

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);| |~~readLunarDate~~(currently working on this)| 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 | ខែចន្ទគតិ | មិគសិរ | | 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