Skip to content

BalineseDate is a open source library to develop Balinese Saka Calendar (Kalender Bali) in Javascript.

License

Notifications You must be signed in to change notification settings

peradnya/balinese-date-js-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BalineseDate Javascript Library

pipeline status coverage report

Introduction

BalineseDate is an open source javascript library to build Balinese Saka Calendar in HTML-page or NodeJS.

Note: This library is in Beta Phase, the API may change without notice.

Features

BalineseDate is designed to be immutable. BalineseDate have several features like:

BalineseDate also have several utilities that can be use by developer like:

  • Filter BalineseDate(s) from selected Date (v0.2.0)
  • Filter BalineseDate(s) from selected BalineseDate List (v0.4.0)
  • List of Rahinan given the BalineseDate (v0.4.2)

Import BalineseDate into Your Project

BalineseDate Javascript Library use unpkg as repository to publish UMD Library, and also use npmjs.com as repository to publish NodeJS Library.

To import BalineseDate to your project, please choose one of these following method:

Direct Download

NPM Install

NPM

Documentation

How to Build

Requirement

The recomended requirement to build this project are:

  1. Latest NodeJS (Recomended >= 10.x)
  2. Latest Git Client

Download and Install BalineseDate Depedencies

To install NPM depedencies that nessesary to build this project, you should execute the command below:

[project root]$ npm install

Building BalineseDate Library

To build all type of BalineseDate Libraries (NodeJS library, UMD library, and production-ready UMD library), you should execute the command below:

[project root]$ npm run build

If you only need to build specific type of BalineseDate library, you can execute the commands below:

# Build NodeJS Library
[project root]$ npm run build:nodejs

# Build UMD Library
[project root]$ npm run build:umd

# Build production-ready UMD Library
[project root]$ npm run build:umd-dist

Building Documentation (Typedoc)

Documentation of BalineseDate Library can be built by executing the command below:

[project root]$ npm run doc

You can find the documentation at:

[project root]/doc/index.html

Testing & Checking

Testing and checking of BalineseDate Library can be done by executing the command below:

[project root]$ npm run test

To build test result, you should enter the command below:

[project root]$ npm run report

You could find the test results at:

[project root]/coverage/lcov-report/index.html

Using in Code

ES6/Typescript Approach

BalineseDate support Typescript by implementing declaration file *.d.ts inside the NodeJS library.

Below code is an example of how to use of BalineseDate (NodeJS version) library in Typescript *.ts file:

import { BalineseDate } from "balinese-date-js-lib";

const now = new BalineseDate();

console.log(now.saka); // show the saka
console.log(now.sasih.name); // show the sasih name
console.log(now.wuku.name); // show the wuku name

CommonJS (NodeJS) Approach

Below code is an example of how to use of BalineseDate (UMD or NodeJS version) library using CommonJS (NodeJS) approach:

const BD = require('balinese-date-js-lib');

const now = new BD.BalineseDate();

console.log(now.saka); // show the saka
console.log(now.sasih.name); // show the sasih name
console.log(now.wuku.name); // show the wuku name

RequireJS (AMD) Approach

Below code is an example of how to use of BalineseDate (UMD version) library via RequireJS (AMD):

<script src="require.js"></script>
<script src="balinese-date-js-lib.min.js"></script>
<script>
    requirejs(["BalineseDate"], function(BD) {
      var now = new BD.BalineseDate();

      document.getElementById("saka").innerHTML = now.saka;
      document.getElementById("sasih").innerHTML = now.sasih.name;
      document.getElementById("wuku").innerHTML = now.wuku.name;
    });
</script>

The example(s) of how to use UMD version of BalineseDate library via require.js in the HTML-page are available at:

[project root]/example/webpage/today-requirejs.html

HTML-page "Direct" Approach

Below code is an example of how to use of BalineseDate (UMD version) library directly in the HTML-page:

<script src="balinese-date-js-lib.min.js"></script>
<script>
    var BD = window.BalineseDate;
    var now = new BD.BalineseDate();

    document.getElementById("saka").innerHTML = now.saka;
    document.getElementById("sasih").innerHTML = now.sasih.name;
    document.getElementById("wuku").innerHTML = now.wuku.name;
</script>

The example(s) of how to use UMD version of BalineseDate library directly in the HTML-page are available at:

[project root]/example/webpage/today.html

References

  • Ardhana, I.B.S. (2005). "Pokok-Pokok Wariga". Surabaya : Paramita.
  • babadbali.com (Yayasan Bali Galang) for wewaran and paringkelan algorithm.
  • Pendit, Nyoman. (2001). "Nyepi: kebangkitan, toleransi, dan kerukunan". Jakarta : Gramedia. Retrieved at google book.
  • kalenderbali.org and kalenderbali.info for validation and building sample test-cases.