Documentation ¶
Index ¶
- Constants
- Variables
- func Convert(year, month, day int, to convertTo) (toyear, tomonth, today int)
- func FromJTime(t JTime) time.Time
- func Since(j JTime) time.Duration
- type JTime
- func (j JTime) Add(d time.Duration) JTime
- func (j JTime) AddDate(year, month, day int) JTime
- func (j JTime) AppendFormat(b []byte, layout string) []byte
- func (j JTime) Before(u JTime) bool
- func (j JTime) Date() (year, month, day int)
- func (j JTime) Day() int
- func (j JTime) Equal(u JTime) bool
- func (j JTime) Format(layout string) string
- func (j JTime) Hour() int
- func (j JTime) ISOWeekday() Weekday
- func (j JTime) In(loc *time.Location) JTime
- func (j JTime) IsLeap() bool
- func (j JTime) Location() *time.Location
- func (j JTime) Minute() int
- func (j JTime) Month() Month
- func (j JTime) Second() int
- func (j JTime) String() string
- func (j JTime) Sub(u JTime) time.Duration
- func (j JTime) SubDuration(d time.Duration) JTime
- func (j JTime) Time() time.Time
- func (j JTime) Unix() int64
- func (j JTime) Weekday() Weekday
- func (j JTime) Year() int
- func (j JTime) YearDay() int
- func (j JTime) YearWeek() int
- type Month
- type Weekday
Constants ¶
const ( ToJalaali convertTo = 1 << iota ToGregorian )
const ( Layout = "01/02 03:04:05 '06" ANSIC = "Monday January 02 15:04:05 2006" RFC822 = "02 January 06 15:04" RFC850 = "Monday, 02-January-06 15:04:05" RFC1123 = "Monday, 02 January 2006 15:04:05" Kitchen = "03:04" Stamp = "January 02 15:04:05" )
These are predefined layouts for use in Time.Format and time.Parse.
Year: "2006" "06" Month: "January" Textual day of the week: "Monday" Numeric day of the month: "2" "02" Numeric day of the year: "002" Hour: "15" "03" Minute: "4" "04" Second: "5" "05"
Variables ¶
var (
TehranTimeZone, _ = time.LoadLocation("Asia/Tehran")
)
Asia/Tehran timezone
Functions ¶
func Convert ¶
Convert converts gregorian date to jalaali date, or jalaali date to gregorian date.
Convert gregorian date to Jalaali date:
Convert(2022, 4, 28, jtime.ToJalaali)
Convert Jalaali date to gregorian date:
Convert(1401, 2, 8, jtime.ToGregorian)
returns 0, 0, 0 if 'to' parameter is invalid.
Types ¶
type JTime ¶
type JTime struct {
// contains filtered or unexported fields
}
A JDate represents an instant in time with nanosecond precision.
func Date ¶
Date returns the Time corresponding to
yyyy-mm-dd hh:mm:ss + nsec nanoseconds
If loc is nil, use time.Local
func Now ¶
func Now() JTime
Now returns the current Jalaali time
it is shorthand for jtime.FromTime(time.Now())
func Parse ¶
Parse uses time.Parse to parse formatted value.
NOTE: Parse cannots parse jtime formatted strings.
It is shorthand for jtime.FromTime(time.Parse(...))
func (JTime) AddDate ¶
AddDate returns the time corresponding to adding the given number of years, months, and days to j.
func (JTime) AppendFormat ¶
AppendFormat is like Format but appends the textual representation to b and returns the extended buffer.
func (JTime) Equal ¶
Equal reports whether t and u represent the same time instant. Two times can be equal even if they are in different locations. For example, 6:00 +0200 and 4:00 UTC are Equal. See the documentation on the Time type for the pitfalls of using == with Time values; most code should use Equal instead.
func (JTime) Format ¶
Format returns a textual representation of the time value formatted according to the layout defined by the argument.
Supported Layout's:
Year: "2006" "06" Month: "January" Textual day of the week: "Monday" Numeric day of the month: "2" "02" Numeric day of the year: "002" Hour: "15" "03" Minute: "4" "04" Second: "5" "05"
func (JTime) In ¶
In returns a copy of t representing the same time instant, but with the copy's location information set to loc for display purposes.
In panics if loc is nil.
func (JTime) Minute ¶
Minute returns the minute offset within the hour specified by j, in the range [0, 59].
func (JTime) Second ¶
Second returns the second offset within the minute specified by j, in the range [0, 59].
func (JTime) String ¶
String returns the time formatted using the format string
"2006-01-02 15:04:05"
func (JTime) Sub ¶
Sub returns the duration t-u. If the result exceeds the maximum (or minimum) value that can be stored in a Duration, the maximum (or minimum) duration will be returned. To compute j-d for a duration d, use j.Add(-d).
type Month ¶
type Month int8
A Month specifies a month of the year (فروردین = 1, ...)