persian

package
v2.6.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2025 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package persian is part of the carbon package.

Index

Constants

This section is empty.

Variables

View Source
var (
	EnMonths = []string{"Farvardin", "Ordibehesht", "Khordad", "Tir", "Mordad", "Shahrivar", "Mehr", "Aban", "Azar", "Dey", "Bahman", "Esfand"}
	FaMonths = []string{"فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"}

	EnWeeks = []string{"Yekshanbeh", "Doshanbeh", "Seshanbeh", "Chaharshanbeh", "Panjshanbeh", "Jomeh", "Shanbeh"}
	FaWeeks = []string{"نجشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}
)

Functions

This section is empty.

Types

type Locale added in v2.6.4

type Locale string
const (
	EnLocale Locale = "en"
	FaLocale Locale = "fa"
)

type Persian

type Persian struct {
	Error error
	// contains filtered or unexported fields
}

Persian defines a Persian struct.

func FromStdTime added in v2.6.2

func FromStdTime(t time.Time) (p *Persian)

FromStdTime creates a Persian instance from standard time.Time.

func NewPersian added in v2.6.2

func NewPersian(year, month, day int) *Persian

NewPersian returns a new Persian instance.

func (*Persian) Day

func (p *Persian) Day() int

Day gets the Persian day like 5.

func (*Persian) IsLeapYear

func (p *Persian) IsLeapYear() bool

IsLeapYear reports whether the Persian year is a leap year.

func (*Persian) IsValid added in v2.5.2

func (p *Persian) IsValid() bool

IsValid reports whether the Persian date is valid.

func (*Persian) Month

func (p *Persian) Month() int

Month gets the Persian month like 8.

func (*Persian) String

func (p *Persian) String() string

String implements the "Stringer" interface for Persian.

func (*Persian) ToGregorian

func (p *Persian) ToGregorian(timezone ...string) *calendar.Gregorian

ToGregorian converts Persian instance to Gregorian instance.

func (*Persian) ToMonthString

func (p *Persian) ToMonthString(locale ...Locale) (month string)

ToMonthString outputs a string in Persian month format like "فروردین".

func (*Persian) ToWeekString

func (p *Persian) ToWeekString(locale ...Locale) (month string)

ToWeekString outputs a string in week layout like "چهارشنبه".

func (*Persian) Year

func (p *Persian) Year() int

Year gets the Persian year like 2020.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL