Methods
date.clone()
Create an independent deep clone of an existing NepaliDate instance.
The clone method creates and returns an independent duplicate of the current NepaliDate instance. Because several library arithmetic and mutation methods alter instances in place, creating a clone allows you to perform calculations without modifying the original date object.
Import
from nepali_date_library import NepaliDateSignature
def clone(self) -> NepaliDate:Parameters
- None.
Return Value
- Type:
NepaliDate - Description: A new independent
NepaliDateinstance with identical coordinates and timestamp.
Example
from nepali_date_library import NepaliDate
original = NepaliDate("2081-07-15")
duplicate = original.clone()
# Mutating duplicate does not affect original
duplicate.add_days(10)
print(original.format("YYYY-MM-DD")) # "2081-07-15"
print(duplicate.format("YYYY-MM-DD")) # "2081-07-25"Related
NepaliDate Constructor: Copy constructor support.date.add_days(): In-place day arithmetic.
Advertisement
date.format()
Format a NepaliDate instance into a custom string using token patterns for English and Nepali output.
NepaliDate.is_valid()
Static validation function to verify whether a given year, month, and day combination forms a valid Bikram Sambat date.