knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

jalcal: an R package to convert Jalaali and Gregorian calendar dates

R-CMD-check CRAN Version CRAN Downloads

Overview

The Persian or Jalaali calendar, also called the Solar Hijri or Hijri Shamsi calendar, is a 12-month system.

Borkowski, K. M. (1996). The Persian calendar for 3000 years. Earth, Moon, and Planets, 74, 223–230. doi:10.1007/BF00055188

Installation

To install the development version of jalcal from GitHub, use the remotes package:

# Install remotes if not already installed
install.packages("remotes")

# Install getsat from GitHub
remotes::install_github("jalilian/jalcal")

To install the package from CRAN, use the install.packages command:

# install.packages('jalcal')

Example 1: Convert Jalaali dates to Gregorian dates

To convert Jalaali dates (e.g., 1403-12-30 and 1404-01-01) to Gregorian dates, use:

library("jalcal")
dates <- jal2greg(year=c(1403, 1404), month=c(12, 1), day=c(30, 1))
print(dates)

Example 2: Convert Gregorian dates to Jalaali dates

To convert Gregorian dates to Jalaali dates, use:

set.seed(14040101)
gdates <- sample(seq.Date(from = as.Date("561-01-01"), 
                                to = as.Date("3177-12-31"), by = "day"), 
                       size = 100)
jdates <- greg2jal(gdates)
cbind(gdates, jdates)


jalilian/jalcal documentation built on April 17, 2025, 2:57 p.m.