Methods
date.set_english_date()
Update internal Bikram Sambat coordinates from a native Python datetime object.
The set_english_date method converts a native Python datetime object into Bikram Sambat coordinates and updates the current NepaliDate instance in place. It recalculates the year, month, and day coordinates based on historical ephemeris tables.
Import
from nepali_date_library import NepaliDateSignature
def set_english_date(self, date: datetime) -> None:Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
date | datetime | Yes | Gregorian datetime object to convert. |
Return Value
- Type:
None - Note: Mutates the current instance in place.
Example
from datetime import datetime, timezone
from nepali_date_library import NepaliDate
nd = NepaliDate()
gregorian = datetime(2023, 4, 14, tzinfo=timezone.utc)
nd.set_english_date(gregorian)
print(nd.format("YYYY-MM-DD")) # "2080-01-01"Related
date.get_english_date(): Retrieve Gregorian datetime object.ADtoBS(): Standalone string conversion.
Advertisement
date.set_date()
Set the day of the month on a NepaliDate instance and recalculate its timestamp.
date.parse()
Parse a formatted Bikram Sambat date string and update the current date instance in place.