Documentation ¶
Overview ¶
Package ptime provides functionality for implementation of Persian (Solar Hijri) Calendar.
Index ¶
- func Afghanistan() *time.Location
- func Iran() *time.Location
- type AmPm
- type DayTime
- type Month
- type Time
- func (t Time) Add(d time.Duration) Time
- func (t Time) AddDate(years, months, days int) Time
- func (t Time) AmPm() AmPm
- func (t *Time) At(hour, min, sec, nsec int)
- func (t Time) BeginningOfMonth() Time
- func (t Time) BeginningOfWeek() Time
- func (t Time) BeginningOfYear() Time
- func (t Time) Clock() (int, int, int)
- func (t Time) Date() (int, Month, int)
- func (t Time) Day() int
- func (t Time) DayTime() DayTime
- func (t Time) FirstMonthDay() Time
- func (t Time) FirstWeekDay() Time
- func (t Time) FirstYearDay() Time
- func (t Time) Format(format string) string
- func (t Time) Hour() int
- func (t Time) Hour12() int
- func (t Time) In(loc *time.Location) Time
- func (t Time) IsLeap() bool
- func (t Time) IsZero() bool
- func (t Time) LastMonthDay() Time
- func (t Time) LastWeekday() Time
- func (t Time) LastYearDay() Time
- func (t Time) Location() *time.Location
- func (t Time) Minute() int
- func (t Time) Month() Month
- func (t Time) MonthWeek() int
- func (t Time) Nanosecond() int
- func (t Time) RMonthDay() int
- func (t Time) RYearDay() int
- func (t Time) RYearWeek() int
- func (t Time) Second() int
- func (t *Time) Set(year int, month Month, day, hour, min, sec, nsec int, loc *time.Location)
- func (t *Time) SetDay(day int)
- func (t *Time) SetHour(hour int)
- func (t *Time) SetMinute(min int)
- func (t *Time) SetMonth(month Month)
- func (t *Time) SetNanosecond(nsec int)
- func (t *Time) SetSecond(sec int)
- func (t *Time) SetTime(ti time.Time)
- func (t *Time) SetUnix(sec, nsec int64)
- func (t *Time) SetYear(year int)
- func (t Time) Since(t2 Time) int64
- func (t Time) String() string
- func (t Time) Time() time.Time
- func (t Time) TimeFormat(format string) string
- func (t Time) Tomorrow() Time
- func (t Time) Unix() int64
- func (t Time) UnixNano() int64
- func (t Time) Weekday() Weekday
- func (t Time) Year() int
- func (t Time) YearDay() int
- func (t Time) YearWeek() int
- func (t Time) Yesterday() Time
- func (t Time) Zone() (string, int)
- func (t Time) ZoneOffset(f ...string) string
- type Weekday
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Afghanistan ¶
Afghanistan returns a pointer to time.Location of Asia/Kabul
Types ¶
type AmPm ¶
type AmPm int
A AmPm specifies the 12-Hour marker.
type DayTime ¶ added in v1.1.0
type DayTime int
A DayTime represents a part of the day based on hour.
List of day times.
type Month ¶
type Month int
A Month specifies a month of the year starting from Farvardin = 1.
const ( Farvardin Month = 1 + iota Ordibehesht Khordad Tir Mordad Shahrivar Mehr Aban Azar Dey Bahman Esfand )
List of months in Persian calendar.
List of Dari months in Persian calendar.
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
A Time represents a moment in time in Persian (Jalali) Calendar.
func Date ¶
Date returns a new instance of Time.
year, month and day represent a day in Persian calendar.
hour, min minute, sec seconds, nsec nanoseconds offsets represent a moment in time.
loc is a pointer to time.Location, if loc is nil then the local time is used.
func New ¶
New converts Gregorian calendar to Persian calendar and
returns a new instance of Time corresponding to the time of t or a zero instance of time if Gregorian year is less than 1097.
t is an instance of time.Time in Gregorian calendar.
func Unix ¶
Unix returns a new instance of PersianDate from unix timestamp.
sec seconds and nsec nanoseconds since January 1, 1970 UTC.
func (Time) AddDate ¶
AddDate returns a new instance of Time for t.year+years, t.month+months and t.day+days.
func (Time) BeginningOfMonth ¶ added in v0.5.0
BeginningOfMonth returns a new instance of Time representing the first day of the month of t. The time is reset to 00:00:00
func (Time) BeginningOfWeek ¶ added in v0.5.0
BeginningOfWeek returns a new instance of Time representing the first day of the week of t. The time is reset to 00:00:00
func (Time) BeginningOfYear ¶ added in v0.5.0
BeginningOfYear returns a new instance of Time representing the first day of the year of t. The time is reset to 00:00:00
func (Time) DayTime ¶ added in v1.1.0
DayTime returns the dayTime of that part of the day. [0,3) -> midnight [3,6) -> dawn [6,9) -> morning [9,12) -> before noon [12,15) -> noon [15,18) -> afternoon [18,21) -> evening [21,24) -> night
func (Time) FirstMonthDay ¶
FirstMonthDay returns a new instance of Time representing the first day of the month of t.
func (Time) FirstWeekDay ¶
FirstWeekDay returns a new instance of Time representing the first day of the week of t.
func (Time) FirstYearDay ¶
FirstYearDay returns a new instance of Time representing the first day of the year of t.
func (Time) Format ¶
Format returns the formatted representation of t.
yyyy, yyy, y year (e.g. 1394) yy 2-digits representation of year (e.g. 94) MMM the Persian name of month (e.g. فروردین) MMI the Dari name of month (e.g. حمل) MM 2-digits representation of month (e.g. 01) M month (e.g. 1) rw remaining weeks of year w week of year RW remaining weeks of month W week of month RD remaining days of year D day of year rd remaining days of month dd 2-digits representation of day (e.g. 01) d day (e.g. 1) E the Persian name of weekday (e.g. شنبه) e the Persian short name of weekday (e.g. ش) A the Persian name of 12-Hour marker (e.g. قبل از ظهر) a the Persian short name of 12-Hour marker (e.g. ق.ظ) HH 2-digits representation of hour [00-23] H hour [0-23] kk 2-digits representation of hour [01-24] k hour [1-24] hh 2-digits representation of hour [01-12] h hour [1-12] KK 2-digits representation of hour [00-11] K hour [0-11] mm 2-digits representation of minute [00-59] m minute [0-59] ss 2-digits representation of seconds [00-59] s seconds [0-59] n hour name (e.g. صبح) ns nanoseconds S 3-digits representation of milliseconds (e.g. 001) z the name of location Z zone offset (e.g. +03:30)
func (Time) LastMonthDay ¶
LastMonthDay returns a new instance of Time representing the last day of the month of t.
func (Time) LastWeekday ¶
LastWeekday returns a new instance of Time representing the last day of the week of t.
func (Time) LastYearDay ¶
LastYearDay returns a new instance of Time representing the last day of the year of t.
func (Time) Nanosecond ¶
Nanosecond returns the nanoseconds offset of t in the range [0, 999999999].
func (*Time) Set ¶
Set sets t.
year, month and day represent a day in Persian calendar.
hour, min minute, sec seconds, nsec nanoseconds offsets represent a moment in time.
loc is a pointer to time.Location and must not be nil.
func (*Time) SetNanosecond ¶
SetNanosecond sets the nanosecond offset of t.
func (*Time) SetTime ¶
SetTime sets the time and testDate for the `Time` struct based on the input `time.Time` object. This function converts a Gregorian testDate (as provided by `ti`) to the Shamsi (Persian) calendar. It first calculates the Julian Day Number (JDN), a continuous count of days since the beginning of the Julian Period, and then converts this JDN to a Shamsi testDate.
func (*Time) SetUnix ¶
SetUnix sets t to represent the corresponding unix timestamp of
sec seconds and nsec nanoseconds since January 1, 1970 UTC.
func (Time) Time ¶
Time converts the Shamsi (Solar Hijri) testDate stored in the Time struct to the corresponding Gregorian testDate and returns it as a Go time.Time object.
func (Time) TimeFormat ¶ added in v0.6.0
TimeFormat formats in standard time format.
2006 four digit year (e.g. 1399) 06 two digit year (e.g. 99) 01 two digit month (e.g. 01) 1 one digit month (e.g. 1) Jan month name (e.g. آذر) January month name (e.g. آذر) 02 two digit day (e.g. 07) 2 one digit day (e.g. 7) _2 right justified two character day (e.g. 7) Mon weekday (e.g. شنبه) Monday weekday (e.g. شنبه) Morning hour name (e.g. صبح) 03 two digit 12 hour format (e.g. 03) 3 one digit 12 hour format (e.g. 3) 15 two digit 24 hour format (e.g. 15) 04 two digit minute (e.g. 03) 4 one digit minute (e.g. 03) 05 two digit minute (e.g. 09) 5 one digit minute (e.g. 9) .000 millisecond (e.g. .120) .000000 microsecond (e.g. .123400) .000000000 nanosecond (e.g. .123456000) .999 trailing zeros removed millisecond (e.g. .12) .999999 trailing zeros removed microsecond (e.g. .1234) .999999999 trailing zeros removed nanosecond (e.g. .123456) PM full 12-Hour marker (e.g. قبل از ظهر) pm short 12-Hour marker (e.g. ق.ظ) MST the name of location -0700 zone offset (e.g. +0330) -07 zone offset (e.g. +03) -07:00 zone offset (e.g. +03:30) Z0700 zone offset (e.g. +0330) Z07:00 zone offset (e.g. +03:30)
func (Time) Tomorrow ¶
Tomorrow returns a new instance of Time representing a day after the day of t.
func (Time) Yesterday ¶
Yesterday returns a new instance of Time representing a day before the day of t.
func (Time) ZoneOffset ¶
ZoneOffset returns the zone offset of t in the format of [+|-]HH:mm. If `f` is set, then return format is based on `f`.