Documentation ¶
Overview ¶
Package persian is part of the carbon package.
Index ¶
- Variables
- type Gregorian
- type Month
- type Persian
- func (p Persian) Day() int
- func (p Persian) Hour() int
- func (p Persian) IsLeapYear() bool
- func (p Persian) IsValid() bool
- func (p Persian) Minute() int
- func (p Persian) Month() int
- func (p Persian) Second() int
- func (p Persian) String() string
- func (p Persian) ToGregorian() (g Gregorian)
- func (p Persian) ToMonthString(locale ...string) (month string)
- func (p Persian) ToShortMonthString(locale ...string) (month string)
- func (p Persian) ToShortWeekString(locale ...string) (month string)
- func (p Persian) ToWeekString(locale ...string) (month string)
- func (p Persian) Year() int
Constants ¶
This section is empty.
Variables ¶
var ( EnMonths = []string{"Farvardin", "Ordibehesht", "Khordad", "Tir", "Mordad", "Shahrivar", "Mehr", "Aban", "Azar", "Dey", "Bahman", "Esfand"} ShortEnMonths = []string{"Far", "Ord", "Kho", "Tir", "Mor", "Sha", "Meh", "Aba", "Aza", "Dey", "Bah", "Esf"} FaMonths = []string{"فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"} ShortFaMonths = []string{"فرو", "ارد", "خرد", "تیر", "مرد", "شهر", "مهر", "آبا", "آذر", "دی", "بهم", "اسف"} EnWeeks = []string{"Yekshanbeh", "Doshanbeh", "Seshanbeh", "Chaharshanbeh", "Panjshanbeh", "Jomeh", "Shanbeh"} ShortEnWeeks = []string{"Yek", "Dos", "Ses", "Cha", "Pan", "Jom", "Sha"} FaWeeks = []string{"نجشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"} ShortFaWeeks = []string{"پ", "چ", "س", "د", "ی", "ش", "ج"} InvalidDateError = func() error { return fmt.Errorf("invalid persian date, please make sure the date is valid") } )
Functions ¶
This section is empty.
Types ¶
type Gregorian ¶
Gregorian defines a Gregorian struct. 定义 Gregorian 结构体
func FromGregorian ¶
FromGregorian creates a Gregorian instance from time.Time. 从标准 time.Time 创建 Gregorian 实例
type Persian ¶
type Persian struct { Error error // contains filtered or unexported fields }
Persian defines a Persian struct. 定义 Persian 结构体
func FromPersian ¶
FromPersian creates a Persian instance from persian datetime. 从 波斯日期 创建 Persian 实例
func MaxValue ¶ added in v2.5.2
func MaxValue() Persian
MaxValue returns a Persian instance for the greatest supported date. 返回 Persian 的最大值
func MinValue ¶ added in v2.5.2
func MinValue() Persian
MinValue returns a Persian instance for the lowest supported date. 返回 Persian 的最小值
func (Persian) IsLeapYear ¶
IsLeapYear reports whether is a persian leap year. 是否是闰年
func (Persian) String ¶
String implements Stringer interface and outputs a string in YYYY-MM-DD HH::ii::ss format like "1402-11-11 00:00:00". 实现 Stringer 接口, 输出 YYYY-MM-DD HH::ii::ss 格式字符串,如 "1402-11-11 00:00:00"
func (Persian) ToGregorian ¶
ToGregorian converts Persian instance to Gregorian instance. 将 Persian 实例转化为 Gregorian 实例
func (Persian) ToMonthString ¶
ToMonthString outputs a string in persian month format like "فروردین". 获取完整月份字符串,如 "فروردین"
func (Persian) ToShortMonthString ¶ added in v2.5.2
ToShortMonthString outputs a short string in persian month format like "فروردین". 获取缩写月份字符串,如 "فروردین"
func (Persian) ToShortWeekString ¶ added in v2.5.2
ToShortWeekString outputs a short string in week layout like "چهارشنبه". 输出缩写星期字符串,如 "چهارشنبه"
func (Persian) ToWeekString ¶
ToWeekString outputs a string in week layout like "چهارشنبه". 输出完整星期字符串,如 "چهارشنبه"