കൊല്ലവർഷം - node.js API (v0.5.0)
Show:

Kollavarsham Class

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 this instance.

Constructor

Kollavarsham

(
  • [options]
)

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

    • [longitude=75.8] Number optional

      Sets the longitude for the location for the conversions

    • [outputformat='verbose'] String optional

      Set to 'list' or 'verbose' for the output

Example:

var Kollavarsham = require('kollavarsham');

var options = {
 system: 'SuryaSiddhanta',
 latitude: 10,
 longitude: 76.2,
 outputFormat: 'verbose'
};

var kollavarsham = new Kollavarsham(options);

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

var today = kollavarsham.toGregorianDate(todayInMalayalamEra);

Methods

fromGregorianDate

(
  • date
)
KollavarshamDate

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

getSettings

() Object

Gets a snapshot of the current settings

Returns:

Object:

The current snapshot of the settings/configuration

setLatitude

(
  • latitude
)

Sets the latitude for the location that will be used as the basis for the conversion

Parameters:

  • latitude Object

Example:

var Kollavarsham = require('Kollavarsham');
var kollavarsham = new Kolavarsham({});
kollavarsham.setLatitude(8.5);

setLongitude

(
  • longitude
)

Sets the longitude for the location that will be used as the basis of the conversion

Parameters:

  • longitude Object

Example:

var Kollavarsham = require('Kollavarsham');
var kollavarsham = new Kolavarsham({});
kollavarsham.setLongitude(77.0);

setOutput

(
  • output
)

Sets the output to be as 'list' or 'verbose'

Parameters:

  • output String

    Valid values are 'verbose' (default) and 'list'

setSystem

(
  • system
)

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

Parameters:

  • system String

Example:

var Kollavarsham = require('Kollavarsham');
var kollavarsham = new Kolavarsham({});
kollavarsham.setSystem('InPancasiddhantika');
kollavarsham.setInputDate(new Date(2014, 2, 14));
kollavarsham.convert();

toGregorianDate

(
  • date
)
Date | JulianDate

Converts a Kollavarsham date 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 is still work in progress

Parameters:

Returns:

Date | JulianDate:

Converted date

Properties

_settings

Object private

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

kollavarshamDate

KollavarshamDate static

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:

var Kollavarsham = require('kollavarsham');
var KollavarshamDate = require('kollavarsham').kollavarshamDate;

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