jal2greg {jalcal} | R Documentation |
Convert Jalaali (Persian) Calendar Date to Gregorian Calendar Date
Description
This function converts a date from the Jalaali (Persian) calendar to the Gregorian calendar. It supports both single date conversions and vectorized operations for multiple dates.
Usage
jal2greg(year, month, day)
Arguments
year |
An integer or a vector of integers representing the Jalali year(s). |
month |
An integer or a vector of integers representing the Jalali month(s) (1-12). |
day |
An integer or a vector of integers representing the Jalali day(s) (1-31). |
Details
The function first verifies that the input values are valid Jalali dates, ensuring that: - The 'year' values are finite integers. - The 'month' values range from 1 to 12. - The 'day' values are within valid ranges (1-31), considering month-specific limits.
The conversion is performed in two steps: 1. The function determines the Gregorian start date of the given Jalaali year using the 'jalLeap()' function. This function provides the corresponding Gregorian year and the day in March when the Jalaali year begins. 2. The exact Gregorian date is then calculated by adding the number of days elapsed since the start of the Jalaali year.
Value
A 'Date' object or a vector of 'Date' objects representing the corresponding Gregorian date(s). If any input value is invalid, 'NA' is returned for that entry.
See Also
- jalLeap for computing leap year information. - greg2jal for converting Jalaali dates to Gregorian dates
Examples
# Convert a single Jalaali date to Gregorian
jal2greg(1402, 1, 1)
# Convert multiple Jalaali dates to Gregorian
jal2greg(c(1403, 1404), c(12, 1), c(30, 1))