Skip to main content

Calculation of Gaurabda calendar (Gaudiya Vaishnava calendar)

Project description

Python library for calculating panchanga calendar with vaisnava events.

Installation

pip install gaurabda

Using

Here are a few examples of code that you can try quickly. Examples are related to calculation of calendar. Before calendar calculation we need to specify location and start date.

We can obtain location object basically in two ways:

  • create new location

# create new location

loc = gcal.GCLocation(data = {
    'latitude': 27.583,
    'longitude': 77.73,
    'tzname': '+5:30 Asia/Calcutta',
    'name': 'Vrindavan, India'
})

List of all timezones can be obtained by calling gcal.GetTimeZones().

  • find location in existing list

# find existing location

loc = gcal.FindLocation(city='Vrindavan')

List of all countries gcal.GetCountries() and list of cities for given country: gcal.GetLocationsForCountry('India'). Function GetLocationsForCountry has optional parameter limit, that takes whole number limiting number of locations returned by this method. Default value is -1, that means there is no limit.

Then we need create date object.

today = gcal.Today()
print(repr(today))

date1 = gcal.GCGregorianDate(text='24 apr 2017')
print(repr(date1))

Constructor for GCGregorianDate contains more optional parameters:

  • year, month, day that are whole natural numbers, year between 1500 - 2500, month 1-12, day according given month

  • shour is from interval 0.0 up to 1.0 where 0.0 is mignight, 0.5 is noon (12:00 PM) and 1.0 is next midnight.

  • tzone is offset from UTC 0:00 in hours, so value +5.5 means offset 5:30, which is actual for India

  • date is existing GCGregorianDate object

  • text can be text form of date (e.g. ‘24 Apr 2017’)

Parameters can be combined with certain succession of evaluation. Parameters are evaluated in this order, where later parameter overrides previous values.

  • text

  • date

  • year

  • month

  • day

  • shour

So for example, to get first day of current month, we may use:

d = gcal.GCGregorianDate(date=gcal.Today(), day=1)

Next step is to create calculation engine for calendar, execute calculation and write results to file:

# create calculation engine and calculate
tc = gcal.TCalendar()
tc.CalculateCalendar(loc,today,365)

# save results in various formats
with open('calendar.txt','wt') as wf:
    tc.write(wf, format='plain')
with open('test/calendar.rtf','wt') as wf:
    tc.write(wf, format='rtf')
with open('test/calendar.html','wt') as wf:
    tc.write(wf)
with open('test/calendar2.html','wt') as wf:
    tc.write(wf, layout='table')
with open('test/calendar.json','wt') as wf:
    tc.write(wf, format='json')
with open('test/calendar.xml','wt') as wf:
    tc.write(wf, format='xml')

Arguments for write method of TCalendar class:

  • stream any text writer, for example subclass of io.TextWriter

  • format this is optional parameter, default value is ‘html’, posible values are: ‘plain’, ‘rtf’, ‘xml’, ‘html’, ‘json’

  • layout this is optional, denotes layout of output. It is effective for ‘html’ format, and possible values are ‘list’ and ‘table’. Default is ‘list’.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gaurabda-0.8.1.tar.gz (145.3 kB view details)

Uploaded Source

Built Distribution

gaurabda-0.8.1-py3-none-any.whl (160.9 kB view details)

Uploaded Python 3

File details

Details for the file gaurabda-0.8.1.tar.gz.

File metadata

  • Download URL: gaurabda-0.8.1.tar.gz
  • Upload date:
  • Size: 145.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for gaurabda-0.8.1.tar.gz
Algorithm Hash digest
SHA256 0c9b0dca987adbeb6a19b582f314dd3943c552ce4740c87c9ad5b1b3c750523e
MD5 307c0e0f23d8934fe36e4eecbe7e06f2
BLAKE2b-256 2b26a9f30fb2d8df898151d6f194b074f9ee58ac4c2b8d379966773ef0d66e5d

See more details on using hashes here.

File details

Details for the file gaurabda-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: gaurabda-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 160.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for gaurabda-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 da0b9398e20f6d944348aeda49c47949045a1d8e3dc2899f3882fb8af1019289
MD5 d88d579251fc0f99f7e439449552055e
BLAKE2b-256 977a712ba5593fcf02384f74bd829347f288e6bdb8cf48435326bc013c83ea2d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page