Kollavarsham Class
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 optionalA set of key value pairs to configure the Kollavarsham instance. All settings are optional.
-
[system='SuryaSiddhanta']
String optionalSet to 'InPancasiddhantika' or 'SuryaSiddhanta' to use the corresponding system
-
[latitude=23.2]
Number optionalSets the latitude for the location for the conversions
-
[longitude=75.8]
Number optionalSets the longitude for the location for the conversions
-
[outputformat='verbose']
String optionalSet 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);
Item Index
Properties
- _settings
- kollavarshamDate static
Methods
fromGregorianDate
-
date
Converts a Gregorian date to the equivalent Kollavarsham date, respecting the current configuration
Parameters:
-
date
DateThe Gregorian date to be converted to Kollavarsham
Returns:
Converted date
getSettings
()
Object
Gets a snapshot of the current settings
Returns:
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
StringValid 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
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:
-
date
KollavarshamDateThe Kollavarsham date to be converted to Gregorian
Returns:
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);