calendar
The Jalali, Hijri and Gregorian calendars: conversion, day arithmetic, month names and time zones.
import calendar
This package works with three calendars: Jalali (Solar Hijri, the official calendar of Iran and Afghanistan), Hijri (lunar) and Gregorian. A date is a plain struct of year, month and day, and each calendar has its own conversion, validation, day arithmetic and month name functions.
The Hijri calendar here is arithmetic: months alternate between 30 and 29 days and are not adjusted by sighting the moon, so a date can be one day off from the official calendar of a given country.
There are three ways to turn an instant into a date: EpochToJalali and its siblings use the machine local time, WallClockJalali takes a fixed time zone such as Tehran, and LoadZone covers zones that observe daylight saving.
Types
Zone
struct Zone| Name | Type | Description |
|---|---|---|
name | str = "UTC" | The zone name. |
ok | bool = false | Whether the zone loaded. |
type_offset | Vector | The offset of each time type, in seconds. |
type_isdst | Vector | Whether each type is daylight saving. |
type_abbrev | Vector | The abbreviation of each type, such as EST. |
times | Vector | The instants at which the offset changes. |
type_at | Vector | The time type in force after each change. |
base_type | int = 0 | The type in force before the first change. |
rule | PosixTZ | The POSIX rule for the years after the last recorded change. |
import calendar
func main:
mut z := calendar.LoadZone("America/New_York")
println z.name, z.ok
winter := 1704067200
summer := 1719792000
println calendar.ZoneOffsetMinutes(z, winter), calendar.ZoneOffsetMinutes(z, summer), calendar.ZoneOffsetSeconds(z, summer)
println calendar.ZoneIsDST(z, winter), calendar.ZoneIsDST(z, summer)
println calendar.ZoneAbbrevAt(z, winter), calendar.ZoneAbbrevAt(z, summer)
tz := calendar.TimeZoneAt(z, summer)
println tz.name, tz.offset_minutes
println calendar.ZoneAt("Asia/Tehran", winter).offset_minutes
e := calendar.ZonedToEpoch(calendar.GregorianDate { year = 2024, month = 6, day = 30 }, calendar.ClockTime { hour = 20 }, z)
println e == summer
calendar.FreeZone(z)
println calendar.LoadZone("Mars/Olympus").ok
mut l := calendar.LocalZone()
println l.ok or not l.ok
calendar.FreeZone(l)
endGregorianDate
struct GregorianDate| Name | Type | Description |
|---|---|---|
year | int = 1970 | The year. |
month | int = 1 | The month, from 1. |
day | int = 1 | The day of the month, from 1. |
import calendar
func main:
g := calendar.GregorianDate { year = 2024, month = 3, day = 20 }
j := calendar.GregorianToJalali(g)
h := calendar.GregorianToHijri(g)
println calendar.FormatGregorian(g), calendar.FormatJalali(j), calendar.FormatHijri(h)
println calendar.FormatJalaliLongFa(j)
println calendar.FormatHijriLongFa(h)
println calendar.FormatHijriLongAr(h)
println calendar.FormatGregorianLongEn(g)
println calendar.FormatGregorian(calendar.JalaliToGregorian(calendar.JalaliDate { year = 1403, month = 1, day = 1 }))
println calendar.FormatGregorian(calendar.HijriToGregorian(calendar.HijriDate { year = 1445, month = 9, day = 1 }))
println calendar.FormatHijri(calendar.JalaliToHijri(j)), calendar.FormatJalali(calendar.HijriToJalali(h))
d := calendar.GregorianToJDN(g)
println d, calendar.JalaliToJDN(j), calendar.HijriToJDN(h)
println calendar.FormatGregorian(calendar.JDNToGregorian(d + 1)), calendar.FormatJalali(calendar.JDNToJalali(d + 1)), calendar.FormatHijri(calendar.JDNToHijri(d + 1))
endJalaliDate
struct JalaliDate| Name | Type | Description |
|---|---|---|
year | int = 1 | The year. |
month | int = 1 | The month, from 1 (Farvardin). |
day | int = 1 | The day of the month, from 1. |
The example for this item is shown with the ones above: calendar-Convert.salam
HijriDate
struct HijriDate| Name | Type | Description |
|---|---|---|
year | int = 1 | The year. |
month | int = 1 | The month, from 1 (Muharram). |
day | int = 1 | The day of the month, from 1. |
The example for this item is shown with the ones above: calendar-Convert.salam
ClockTime
struct ClockTime| Name | Type | Description |
|---|---|---|
hour | int = 0 | The hour, 0 to 23. |
minute | int = 0 | The minute. |
second | int = 0 | The second. |
import calendar
import time
func main:
t := 1710943509
zone := calendar.TZLocal(t)
g := calendar.EpochToGregorian(t)
println calendar.CompareGregorian(g, calendar.WallClockGregorian(t, zone)) == 0
println calendar.CompareJalali(calendar.EpochToJalali(t), calendar.WallClockJalali(t, zone)) == 0
println calendar.CompareHijri(calendar.EpochToHijri(t), calendar.WallClockHijri(t, zone)) == 0
println calendar.FormatClockTime(calendar.EpochToClockTime(t)) == calendar.FormatClockTime(calendar.WallClockTime(t, zone))
j := calendar.JalaliDate { year = 1403, month = 1, day = 1 }
println calendar.JalaliToUnixUTC(j, 14, 5, 9) == t
println calendar.GregorianToUnixUTC(calendar.GregorianDate { year = 2024, month = 3, day = 20 }, 14, 5, 9)
println calendar.HijriToUnixUTC(calendar.HijriDate { year = 1445, month = 9, day = 10 }, 0, 0, 0)
println calendar.CompareGregorian(calendar.TodayGregorian(), calendar.EpochToGregorian(time.Now())) >= 0, calendar.TodayGregorian().year >= 2024, calendar.TodayJalali().year >= 1403, calendar.TodayHijri().year >= 1445
c := calendar.NowClockTime()
println c.hour < 24, c.minute < 60, c.second < 61
endTimeZone
struct TimeZone| Name | Type | Description |
|---|---|---|
name | str = "UTC" | The zone name, such as Asia/Tehran. |
offset_minutes | int = 0 | The offset from UTC in minutes; 210 for Tehran. |
import calendar
func main:
t := 1710943509
tehran := calendar.TZTehran()
println tehran.name, tehran.offset_minutes
println calendar.FormatJalali(calendar.WallClockJalali(t, tehran)), calendar.FormatClockTime(calendar.WallClockTime(t, tehran))
println calendar.FormatGregorian(calendar.WallClockGregorian(t, calendar.TZTokyo())), calendar.FormatClockTime(calendar.WallClockTime(t, calendar.TZTokyo()))
println calendar.FormatHijri(calendar.WallClockHijri(t, calendar.TZMecca()))
each zone in [calendar.TZUTC(), calendar.TZKabul(), calendar.TZRiyadh(), calendar.TZDubai(), calendar.TZIstanbul(), calendar.TZLondon(), calendar.TZNewYork()]:
println zone.name, zone.offset_minutes, calendar.FormatClockTime(calendar.WallClockTime(t, zone))
end
g := calendar.GregorianDate { year = 2024, month = 3, day = 20 }
c := calendar.ClockTime { hour = 23, minute = 0, second = 0 }
println calendar.ZonedGregorianToEpoch(g, c, tehran)
println calendar.FormatGregorian(calendar.ConvertZonedGregorian(g, c, tehran, calendar.TZTokyo())), calendar.FormatClockTime(calendar.ConvertZonedTime(g, c, tehran, calendar.TZTokyo()))
fixed := calendar.FixedOffsetZone("UTC+05:30", 330)
println fixed.name, calendar.FormatClockTime(calendar.WallClockTime(t, fixed))
local := calendar.TZLocal(t)
println local.name, local.offset_minutes == calendar.LocalOffsetMinutes(t)
endFunctions
JalaliToJDN
func JalaliToJDN(d: JalaliDate): i64The example for this item is shown with the ones above: calendar-Convert.salam
JDNToJalali
func JDNToJalali(jdn: i64): JalaliDateThe example for this item is shown with the ones above: calendar-Convert.salam
IsLeapJalali
func IsLeapJalali(year: int): boolimport calendar
func main:
println calendar.IsLeapJalali(1403), calendar.IsLeapJalali(1404), calendar.DaysInJalaliYear(1403)
println calendar.DaysInJalaliMonth(1403, 1), calendar.DaysInJalaliMonth(1403, 7), calendar.DaysInJalaliMonth(1403, 12), calendar.DaysInJalaliMonth(1404, 12)
println calendar.IsValidJalaliDate(1404, 12, 30), calendar.IsValidJalaliDate(1403, 12, 30)
println calendar.JalaliMonthNameFa(1), calendar.JalaliMonthNameEn(1), calendar.JalaliMonthNameFa(12)
j := calendar.JalaliDate { year = 1403, month = 6, day = 31 }
d := calendar.JalaliToJDN(j)
println calendar.JalaliWeekday(d), calendar.JalaliWeekdayNameFa(calendar.JalaliWeekday(d))
println calendar.WeekdayJalali(j), calendar.WeekdayNameFa(calendar.WeekdayJalali(j))
println calendar.FormatJalali(calendar.AddDaysJalali(j, 1)), calendar.FormatJalali(calendar.AddWeeksJalali(j, 2))
println calendar.FormatJalali(calendar.AddMonthsJalali(j, 1)), calendar.FormatJalali(calendar.AddYearsJalali(j, -1))
println calendar.FormatJalali(calendar.StartOfMonthJalali(j)), calendar.FormatJalali(calendar.EndOfMonthJalali(calendar.AddMonthsJalali(j, 6)))
nowruz := calendar.JalaliDate { year = 1404, month = 1, day = 1 }
println calendar.DaysBetweenJalali(j, nowruz), calendar.CompareJalali(j, nowruz), calendar.CompareJalali(nowruz, nowruz)
endDaysInJalaliMonth
func DaysInJalaliMonth(year: int, month: int): intThe example for this item is shown with the ones above: calendar-Jalali.salam
IsValidJalaliDate
func IsValidJalaliDate(year: int, month: int, day: int): boolThe example for this item is shown with the ones above: calendar-Jalali.salam
JalaliMonthNameFa
func JalaliMonthNameFa(month: int): strThe example for this item is shown with the ones above: calendar-Jalali.salam
JalaliMonthNameEn
func JalaliMonthNameEn(month: int): strThe example for this item is shown with the ones above: calendar-Jalali.salam
JalaliWeekday
func JalaliWeekday(jdn: i64): intThe example for this item is shown with the ones above: calendar-Jalali.salam
JalaliWeekdayNameFa
func JalaliWeekdayNameFa(weekday: int): strJalaliWeekday number, where zero is Saturday.The example for this item is shown with the ones above: calendar-Jalali.salam
CompareJalali
func CompareJalali(a: JalaliDate, b: JalaliDate): intThe example for this item is shown with the ones above: calendar-Jalali.salam
GregorianToJalali
func GregorianToJalali(d: GregorianDate): JalaliDateThe example for this item is shown with the ones above: calendar-Convert.salam
JalaliToGregorian
func JalaliToGregorian(d: JalaliDate): GregorianDateThe example for this item is shown with the ones above: calendar-Convert.salam
GregorianToHijri
func GregorianToHijri(d: GregorianDate): HijriDateThe example for this item is shown with the ones above: calendar-Convert.salam
HijriToGregorian
func HijriToGregorian(d: HijriDate): GregorianDateThe example for this item is shown with the ones above: calendar-Convert.salam
JalaliToHijri
func JalaliToHijri(d: JalaliDate): HijriDateThe example for this item is shown with the ones above: calendar-Convert.salam
HijriToJalali
func HijriToJalali(d: HijriDate): JalaliDateThe example for this item is shown with the ones above: calendar-Convert.salam
EpochToGregorian
func EpochToGregorian(epoch: i64): GregorianDateThe example for this item is shown with the ones above: calendar-Epoch.salam
EpochToJalali
func EpochToJalali(epoch: i64): JalaliDateThe example for this item is shown with the ones above: calendar-Epoch.salam
EpochToHijri
func EpochToHijri(epoch: i64): HijriDateThe example for this item is shown with the ones above: calendar-Epoch.salam
EpochToClockTime
func EpochToClockTime(epoch: i64): ClockTimeThe example for this item is shown with the ones above: calendar-Epoch.salam
TodayGregorian
func TodayGregorian(): GregorianDateThe example for this item is shown with the ones above: calendar-Epoch.salam
TodayJalali
func TodayJalali(): JalaliDateThe example for this item is shown with the ones above: calendar-Epoch.salam
TodayHijri
func TodayHijri(): HijriDateThe example for this item is shown with the ones above: calendar-Epoch.salam
NowClockTime
func NowClockTime(): ClockTimeThe example for this item is shown with the ones above: calendar-Epoch.salam
GregorianToUnixUTC
func GregorianToUnixUTC(d: GregorianDate, hour: int, minute: int, second: int): i64The example for this item is shown with the ones above: calendar-Epoch.salam
JalaliToUnixUTC
func JalaliToUnixUTC(d: JalaliDate, hour: int, minute: int, second: int): i64The example for this item is shown with the ones above: calendar-Epoch.salam
HijriToUnixUTC
func HijriToUnixUTC(d: HijriDate, hour: int, minute: int, second: int): i64The example for this item is shown with the ones above: calendar-Epoch.salam
FormatGregorian
func FormatGregorian(d: GregorianDate): str2024-03-20.The example for this item is shown with the ones above: calendar-Convert.salam
FormatJalali
func FormatJalali(d: JalaliDate): str1403-01-01.The example for this item is shown with the ones above: calendar-Convert.salam
FormatHijri
func FormatHijri(d: HijriDate): str1445-09-10.The example for this item is shown with the ones above: calendar-Convert.salam
FormatClockTime
func FormatClockTime(t: ClockTime): str14:05:09.The example for this item is shown with the ones above: calendar-Epoch.salam
FormatJalaliLongFa
func FormatJalaliLongFa(d: JalaliDate): str1 فروردین 1403.The example for this item is shown with the ones above: calendar-Convert.salam
FormatHijriLongAr
func FormatHijriLongAr(d: HijriDate): strThe example for this item is shown with the ones above: calendar-Convert.salam
FormatHijriLongFa
func FormatHijriLongFa(d: HijriDate): str10 رمضان 1445.The example for this item is shown with the ones above: calendar-Convert.salam
FormatGregorianLongEn
func FormatGregorianLongEn(d: GregorianDate): strMarch 20, 2024.The example for this item is shown with the ones above: calendar-Convert.salam
LoadZone
func LoadZone(name: str): ZoneAmerica/New_York, from the system tzdata files. On Windows those files are usually absent and ok stays false.The example for this item is shown with the ones above: calendar-Zone.salam
LocalZone
func LocalZone(): ZoneTZ variable or /etc/localtime.The example for this item is shown with the ones above: calendar-Zone.salam
FreeZone
func FreeZone(z &: Zone)The example for this item is shown with the ones above: calendar-Zone.salam
ZoneOffsetSeconds
func ZoneOffsetSeconds(z: Zone, epoch: i64): intThe example for this item is shown with the ones above: calendar-Zone.salam
ZoneOffsetMinutes
func ZoneOffsetMinutes(z: Zone, epoch: i64): intThe example for this item is shown with the ones above: calendar-Zone.salam
ZoneIsDST
func ZoneIsDST(z: Zone, epoch: i64): boolThe example for this item is shown with the ones above: calendar-Zone.salam
ZoneAbbrevAt
func ZoneAbbrevAt(z: Zone, epoch: i64): strThe example for this item is shown with the ones above: calendar-Zone.salam
TimeZoneAt
func TimeZoneAt(z: Zone, epoch: i64): TimeZoneTimeZone.The example for this item is shown with the ones above: calendar-Zone.salam
ZoneAt
func ZoneAt(name: str, epoch: i64): TimeZoneTimeZone at that instant.The example for this item is shown with the ones above: calendar-Zone.salam
ZonedToEpoch
func ZonedToEpoch(d: GregorianDate, t: ClockTime, z: Zone): i64The example for this item is shown with the ones above: calendar-Zone.salam
GregorianToJDN
func GregorianToJDN(d: GregorianDate): i64The example for this item is shown with the ones above: calendar-Convert.salam
JDNToGregorian
func JDNToGregorian(jdn: i64): GregorianDateThe example for this item is shown with the ones above: calendar-Convert.salam
IsLeapGregorian
func IsLeapGregorian(year: int): boolimport calendar
func main:
println calendar.IsLeapGregorian(2024), calendar.IsLeapGregorian(1900), calendar.DaysInGregorianYear(2024)
println calendar.DaysInGregorianMonth(2024, 2), calendar.DaysInGregorianMonth(2023, 2), calendar.IsValidGregorianDate(2023, 2, 29)
g := calendar.GregorianDate { year = 2024, month = 1, day = 31 }
w := calendar.WeekdayGregorian(g)
println w, calendar.WeekdayNameEn(w), calendar.WeekdayNameFa(w), calendar.WeekdayNameAr(w)
println calendar.Weekday(calendar.GregorianToJDN(g)), calendar.GregorianMonthNameEn(1)
println calendar.FormatGregorian(calendar.AddMonthsGregorian(g, 1)), calendar.FormatGregorian(calendar.AddYearsGregorian(calendar.GregorianDate { year = 2024, month = 2, day = 29 }, 1))
println calendar.FormatGregorian(calendar.AddDaysGregorian(g, 30)), calendar.FormatGregorian(calendar.AddWeeksGregorian(g, -1))
println calendar.FormatGregorian(calendar.StartOfMonthGregorian(g)), calendar.FormatGregorian(calendar.EndOfMonthGregorian(calendar.AddMonthsGregorian(g, 1)))
println calendar.FormatGregorian(calendar.NextWeekdayOnOrAfter(g, 5))
year_end := calendar.GregorianDate { year = 2024, month = 12, day = 31 }
println calendar.DaysBetweenGregorian(g, year_end), calendar.CompareGregorian(year_end, g)
endDaysInGregorianMonth
func DaysInGregorianMonth(year: int, month: int): intThe example for this item is shown with the ones above: calendar-Gregorian.salam
IsValidGregorianDate
func IsValidGregorianDate(year: int, month: int, day: int): boolThe example for this item is shown with the ones above: calendar-Gregorian.salam
Weekday
func Weekday(jdn: i64): intThe example for this item is shown with the ones above: calendar-Gregorian.salam
WeekdayNameEn
func WeekdayNameEn(weekday: int): strWeekday number.The example for this item is shown with the ones above: calendar-Gregorian.salam
WeekdayNameFa
func WeekdayNameFa(weekday: int): strWeekday number, where zero is Sunday.The example for this item is shown with the ones above: calendar-Gregorian.salam
WeekdayNameAr
func WeekdayNameAr(weekday: int): strWeekday number.The example for this item is shown with the ones above: calendar-Gregorian.salam
GregorianMonthNameEn
func GregorianMonthNameEn(month: int): strThe example for this item is shown with the ones above: calendar-Gregorian.salam
CompareGregorian
func CompareGregorian(a: GregorianDate, b: GregorianDate): intThe example for this item is shown with the ones above: calendar-Gregorian.salam
FixedOffsetZone
func FixedOffsetZone(name: str, offsetMinutes: int): TimeZoneThe example for this item is shown with the ones above: calendar-TimeZone.salam
TZUTC
func TZUTC(): TimeZoneThe example for this item is shown with the ones above: calendar-TimeZone.salam
TZTehran
func TZTehran(): TimeZoneThe example for this item is shown with the ones above: calendar-TimeZone.salam
TZKabul
func TZKabul(): TimeZoneThe example for this item is shown with the ones above: calendar-TimeZone.salam
TZRiyadh
func TZRiyadh(): TimeZoneThe example for this item is shown with the ones above: calendar-TimeZone.salam
TZMecca
func TZMecca(): TimeZoneThe example for this item is shown with the ones above: calendar-TimeZone.salam
TZDubai
func TZDubai(): TimeZoneThe example for this item is shown with the ones above: calendar-TimeZone.salam
TZIstanbul
func TZIstanbul(): TimeZoneThe example for this item is shown with the ones above: calendar-TimeZone.salam
TZLondon
func TZLondon(): TimeZoneLoadZone for that.The example for this item is shown with the ones above: calendar-TimeZone.salam
TZNewYork
func TZNewYork(): TimeZoneLoadZone for that.The example for this item is shown with the ones above: calendar-TimeZone.salam
TZTokyo
func TZTokyo(): TimeZoneThe example for this item is shown with the ones above: calendar-TimeZone.salam
LocalOffsetMinutes
func LocalOffsetMinutes(epoch: i64): intThe example for this item is shown with the ones above: calendar-TimeZone.salam
TZLocal
func TZLocal(epoch: i64): TimeZoneLocal carrying the local offset at that instant.The example for this item is shown with the ones above: calendar-TimeZone.salam
WallClockGregorian
func WallClockGregorian(epoch: i64, tz: TimeZone): GregorianDateThe example for this item is shown with the ones above: calendar-TimeZone.salam
WallClockJalali
func WallClockJalali(epoch: i64, tz: TimeZone): JalaliDateThe example for this item is shown with the ones above: calendar-TimeZone.salam
WallClockHijri
func WallClockHijri(epoch: i64, tz: TimeZone): HijriDateThe example for this item is shown with the ones above: calendar-TimeZone.salam
WallClockTime
func WallClockTime(epoch: i64, tz: TimeZone): ClockTimeThe example for this item is shown with the ones above: calendar-TimeZone.salam
ZonedGregorianToEpoch
func ZonedGregorianToEpoch(d: GregorianDate, t: ClockTime, tz: TimeZone): i64The example for this item is shown with the ones above: calendar-TimeZone.salam
ConvertZonedGregorian
func ConvertZonedGregorian(d: GregorianDate, t: ClockTime, from: TimeZone, toTz: TimeZone): GregorianDateThe example for this item is shown with the ones above: calendar-TimeZone.salam
ConvertZonedTime
func ConvertZonedTime(d: GregorianDate, t: ClockTime, from: TimeZone, toTz: TimeZone): ClockTimeThe example for this item is shown with the ones above: calendar-TimeZone.salam
HijriToJDN
func HijriToJDN(d: HijriDate): i64The example for this item is shown with the ones above: calendar-Convert.salam
JDNToHijri
func JDNToHijri(jdn: i64): HijriDateThe example for this item is shown with the ones above: calendar-Convert.salam
IsLeapHijri
func IsLeapHijri(year: int): boolimport calendar
func main:
h := calendar.HijriDate { year = 1445, month = 9, day = 29 }
println calendar.IsLeapHijri(1445), calendar.IsLeapHijri(1446)
println calendar.DaysInHijriMonth(1445, 9), calendar.DaysInHijriMonth(1445, 12), calendar.DaysInHijriMonth(1446, 12)
println calendar.IsValidHijriDate(1445, 9, 30), calendar.IsValidHijriDate(1445, 10, 30)
println calendar.HijriMonthNameFa(9), calendar.HijriMonthNameAr(9), calendar.HijriMonthNameEn(9)
println calendar.FormatHijri(calendar.AddDaysHijri(h, 1)), calendar.FormatHijri(calendar.AddWeeksHijri(h, 1))
println calendar.FormatHijri(calendar.AddMonthsHijri(h, 3)), calendar.FormatHijri(calendar.AddYearsHijri(h, 1))
println calendar.FormatHijri(calendar.StartOfMonthHijri(h)), calendar.FormatHijri(calendar.EndOfMonthHijri(h))
muharram := calendar.HijriDate { year = 1446, month = 1, day = 1 }
println calendar.DaysBetweenHijri(h, muharram), calendar.CompareHijri(h, muharram)
println calendar.WeekdayNameFa(calendar.WeekdayHijri(h))
endDaysInHijriMonth
func DaysInHijriMonth(year: int, month: int): intThe example for this item is shown with the ones above: calendar-Hijri.salam
IsValidHijriDate
func IsValidHijriDate(year: int, month: int, day: int): boolThe example for this item is shown with the ones above: calendar-Hijri.salam
HijriMonthNameAr
func HijriMonthNameAr(month: int): strThe example for this item is shown with the ones above: calendar-Hijri.salam
HijriMonthNameFa
func HijriMonthNameFa(month: int): strThe example for this item is shown with the ones above: calendar-Hijri.salam
HijriMonthNameEn
func HijriMonthNameEn(month: int): strThe example for this item is shown with the ones above: calendar-Hijri.salam
CompareHijri
func CompareHijri(a: HijriDate, b: HijriDate): intThe example for this item is shown with the ones above: calendar-Hijri.salam
AddDaysGregorian
func AddDaysGregorian(d: GregorianDate, n: int): GregorianDaten days to a Gregorian date; a negative n goes back.The example for this item is shown with the ones above: calendar-Gregorian.salam
AddWeeksGregorian
func AddWeeksGregorian(d: GregorianDate, n: int): GregorianDaten weeks to a Gregorian date.The example for this item is shown with the ones above: calendar-Gregorian.salam
AddMonthsGregorian
func AddMonthsGregorian(d: GregorianDate, n: int): GregorianDaten months to a Gregorian date; when the day does not exist in the target month, the last day of that month is used.The example for this item is shown with the ones above: calendar-Gregorian.salam
AddYearsGregorian
func AddYearsGregorian(d: GregorianDate, n: int): GregorianDaten years to a Gregorian date; a leap day missing from the target year moves to the end of the month.The example for this item is shown with the ones above: calendar-Gregorian.salam
DaysBetweenGregorian
func DaysBetweenGregorian(from: GregorianDate, toDate: GregorianDate): i64from to toDate; negative when the second is earlier.The example for this item is shown with the ones above: calendar-Gregorian.salam
StartOfMonthGregorian
func StartOfMonthGregorian(d: GregorianDate): GregorianDateThe example for this item is shown with the ones above: calendar-Gregorian.salam
EndOfMonthGregorian
func EndOfMonthGregorian(d: GregorianDate): GregorianDateThe example for this item is shown with the ones above: calendar-Gregorian.salam
DaysInGregorianYear
func DaysInGregorianYear(year: int): intThe example for this item is shown with the ones above: calendar-Gregorian.salam
AddDaysJalali
func AddDaysJalali(d: JalaliDate, n: int): JalaliDaten days to a Jalali date; a negative n goes back.The example for this item is shown with the ones above: calendar-Jalali.salam
AddWeeksJalali
func AddWeeksJalali(d: JalaliDate, n: int): JalaliDaten weeks to a Jalali date.The example for this item is shown with the ones above: calendar-Jalali.salam
AddMonthsJalali
func AddMonthsJalali(d: JalaliDate, n: int): JalaliDaten months to a Jalali date; when the day does not exist in the target month, the last day of that month is used.The example for this item is shown with the ones above: calendar-Jalali.salam
AddYearsJalali
func AddYearsJalali(d: JalaliDate, n: int): JalaliDaten years to a Jalali date; a leap day missing from the target year moves to the end of the month.The example for this item is shown with the ones above: calendar-Jalali.salam
DaysBetweenJalali
func DaysBetweenJalali(from: JalaliDate, toDate: JalaliDate): i64from to toDate; negative when the second is earlier.The example for this item is shown with the ones above: calendar-Jalali.salam
StartOfMonthJalali
func StartOfMonthJalali(d: JalaliDate): JalaliDateThe example for this item is shown with the ones above: calendar-Jalali.salam
EndOfMonthJalali
func EndOfMonthJalali(d: JalaliDate): JalaliDateThe example for this item is shown with the ones above: calendar-Jalali.salam
DaysInJalaliYear
func DaysInJalaliYear(year: int): intThe example for this item is shown with the ones above: calendar-Jalali.salam
AddDaysHijri
func AddDaysHijri(d: HijriDate, n: int): HijriDaten days to a Hijri date; a negative n goes back.The example for this item is shown with the ones above: calendar-Hijri.salam
AddWeeksHijri
func AddWeeksHijri(d: HijriDate, n: int): HijriDaten weeks to a Hijri date.The example for this item is shown with the ones above: calendar-Hijri.salam
AddMonthsHijri
func AddMonthsHijri(d: HijriDate, n: int): HijriDaten months to a Hijri date; when the day does not exist in the target month, the last day of that month is used.The example for this item is shown with the ones above: calendar-Hijri.salam
AddYearsHijri
func AddYearsHijri(d: HijriDate, n: int): HijriDaten years to a Hijri date; a leap day missing from the target year moves to the end of the month.The example for this item is shown with the ones above: calendar-Hijri.salam
DaysBetweenHijri
func DaysBetweenHijri(from: HijriDate, toDate: HijriDate): i64from to toDate; negative when the second is earlier.The example for this item is shown with the ones above: calendar-Hijri.salam
StartOfMonthHijri
func StartOfMonthHijri(d: HijriDate): HijriDateThe example for this item is shown with the ones above: calendar-Hijri.salam
EndOfMonthHijri
func EndOfMonthHijri(d: HijriDate): HijriDateThe example for this item is shown with the ones above: calendar-Hijri.salam
WeekdayGregorian
func WeekdayGregorian(d: GregorianDate): intWeekday does, with zero Sunday.The example for this item is shown with the ones above: calendar-Gregorian.salam
WeekdayJalali
func WeekdayJalali(d: JalaliDate): intWeekday does, with zero Sunday.The example for this item is shown with the ones above: calendar-Jalali.salam
WeekdayHijri
func WeekdayHijri(d: HijriDate): intWeekday does, with zero Sunday.The example for this item is shown with the ones above: calendar-Hijri.salam
NextWeekdayOnOrAfter
func NextWeekdayOnOrAfter(d: GregorianDate, weekday: int): GregorianDateweekday; the date itself counts.The example for this item is shown with the ones above: calendar-Gregorian.salam