കൊല്ലവർഷം - JavaScript API (v1.3.12)
Show:

Kollavarsham Class

Defined in: lib/index.js:16
Module: kollavarsham

The Kollavarsham class implements all the public APIs of the library.

Create a new instance of this class, passing in the relevant options and call methods on the instance.

Constructor

Kollavarsham

(
  • [options]
)

Defined in lib/index.js:16

Parameters:

  • [options] Object optional

    A set of key value pairs to configure the Kollavarsham instance. All settings are optional.

    • [system='SuryaSiddhanta'] String optional

      Set to 'InPancasiddhantika' or 'SuryaSiddhanta' to use the corresponding system

    • [latitude=23.2] Number optional

      Sets the latitude for the location for the conversions. Defaults to Ujjain, Madhya Pradesh

    • [longitude=75.8] Number optional

      Sets the longitude for the location for the conversions. Default to Ujjain, Madhya Pradesh

Example:

const Kollavarsham = require('kollavarsham');

const options = {
 system: 'SuryaSiddhanta',
 latitude: 10,
 longitude: 76.2
};

const kollavarsham = new Kollavarsham(options);

let todayInMalayalamEra = kollavarsham.fromGregorianDate(new Date());

let today = kollavarsham.toGregorianDate(todayInMalayalamEra);  // Not implemented yet

Methods

fromGregorianDate

(
  • date
)
KollavarshamDate

Defined in lib/index.js:136

Converts a Gregorian date to the equivalent Kollavarsham date, respecting the current configuration

Parameters:

  • date Date

    The Gregorian date to be converted to Kollavarsham

Returns:

KollavarshamDate:

Converted date

Example:

const Kollavarsham = require('Kollavarsham');
const kollavarsham = new Kollavarsham();
let today = kollavarsham.fromGregorianDate(new Date(1979, 4, 22));

getSettings

() System, latitude, longitude

Defined in lib/index.js:59

Gets a snapshot of the current settings

Returns:

System, latitude, longitude:

}

Example:

const Kollavarsham = require('kollavarsham');

const options = {
 system: 'InPancasiddhantika',
 latitude: 10,
 longitude: 76.2
};

const kollavarsham = new Kollavarsham(options);

let currentSettings = kollavarsham.getSettings();

setLatitude

(
  • latitude
)

Defined in lib/index.js:102

Sets the latitude for the location that will be used as the basis for the conversion. The value of the latitude parameter should be within -90 to +90

Parameters:

  • latitude Number

Example:

const Kollavarsham = require('Kollavarsham');
const kollavarsham = new Kollavarsham();
kollavarsham.setLatitude(8.5);

setLongitude

(
  • longitude
)

Defined in lib/index.js:119

Sets the longitude for the location that will be used as the basis of the conversion The value of the latitude parameter should be within -180 to +180

Parameters:

  • longitude Number

Example:

const Kollavarsham = require('Kollavarsham');
const kollavarsham = new Kollavarsham();
kollavarsham.setLongitude(77.0);

setSystem

(
  • system
)

Defined in lib/index.js:83

Sets the system to be either 'InPancasiddhantika' or 'SuryaSiddhanta'

Parameters:

  • system String

Example:

const Kollavarsham = require('Kollavarsham');
const kollavarsham = new Kollavarsham();
kollavarsham.setSystem('InPancasiddhantika');
kollavarsham.setInputDate(new Date(2014, 2, 14));
kollavarsham.convert();

toGregorianDate

(
  • date
)
Date | JulianDate

Defined in lib/index.js:155

Converts a Kollavarsham date (an instance of KollavarshamDate) to its equivalent Gregorian date, respecting the current configuration. This method Will return JulianDate object for any date before 1st January 1583 AD and Date objects for later dates.

This API has not been implemented yet

Parameters:

Returns:

Date | JulianDate:

Converted date

Throws:

"When the API is implemented, will convert <date>"

toGregorianDateFromSaka

(
  • sakaDate
)
Date | JulianDate

Defined in lib/index.js:173

Converts a Saka date (an instance of SakaDate) to its equivalent Gregorian date, respecting the current configuration. This method Will return JulianDate object for any date before 1st January 1583 AD and Date objects for later dates.

Parameters:

  • sakaDate SakaDate

    The Saka date to be converted to Gregorian

Returns:

Date | JulianDate:

Converted date

Properties

KollavarshamDate

KollavarshamDate static

Defined in lib/index.js:196

Exports the KollavarshamDate class for referencing via require. This is the class that is returned when converting fromGregorianDate and is passed in to toGregorianDate. See example below.

Example:

const Kollavarsham = require('kollavarsham');
const KollavarshamDate = Kollavarsham.KollavarshamDate;

let myKollavarshamDate = new KollavarshamDate(1189, 7, 13); // Create a new Malayalam Date representation
let myDateInGregorian = (new Kollavarsham({'system': 'InPancasiddhantika'})).toGregorianDate(myKollavarshamDate);

SakaDate

SakaDate static

Defined in lib/index.js:214

Exports the SakaDate class for referencing via require. This class's instance needs to be passed in to toGregorianDateFromSaka. See example below.

Example:

const Kollavarsham = require('kollavarsham');
const SakaDate = Kollavarsham.SakaDate;

let sakaDate = new SakaDate(1905, 5, 14, 'Suklapaksa'); // Create a new Saka Date representation
let sakaDateInGregorian = (new Kollavarsham()).toGregorianDateFromSaka(sakaDate);

settings

System, latitude, longitude

Defined in lib/index.js:47

Holds the settings state of the Kollavarsham instance. To access a snapshot use the getSettings method