变换波斯语(Jalali日历)约会到格里高利日期

发布于 2025-02-01 18:47:28 字数 200 浏览 3 评论 0原文

一个人如何自动转换 Persian Dates (Jalali/Iranian日历) r的日历?

假设数据格式以几个月/天(例如“ 1.02”)组织一年。

How can one automatically transform Persian dates (Jalali/Iranian calendar) to the dates according to the Gregorian calendar in R?

Suppose the data format is organized in months/day (for example "1.02") without a year.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难如初 2025-02-08 18:47:28

为了使用现有机械,我们必须填写一年的 。 Jalali的当年显然是1401:Greg2jal(sys.date()) is(1401,3,4)。因此,警告之类的东西

mdvec <- c(1.02, 2.03, 3.21)
## separate decimals into month/day
month <- mdvec %/% 1
day <- (mdvec %% 1) * 100
cur_yr <- 1401
year <- rep(cur_yr, length(mdvec))
## convert
library(jalcal)
do.call(c, Map(jal2greg, year, month, day))
## [1] "2022-03-22" "2022-04-22" "2022-06-10"

:我不知道Jalali月/天和Gregorian月份/天之间是否有完美的一对一映射...?

We have to fill in something for the year in order to use the existing machinery. The current year in Jalali is apparently 1401: greg2jal(Sys.Date()) is (1401,3,4). So something like

mdvec <- c(1.02, 2.03, 3.21)
## separate decimals into month/day
month <- mdvec %/% 1
day <- (mdvec %% 1) * 100
cur_yr <- 1401
year <- rep(cur_yr, length(mdvec))
## convert
library(jalcal)
do.call(c, Map(jal2greg, year, month, day))
## [1] "2022-03-22" "2022-04-22" "2022-06-10"

warning: I don't know if there's a perfect one-to-one mapping between Jalali month/day and Gregorian month/day ... ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文