jalaali

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 7 Imported by: 2

README

Jalaali

Structural time package for jalaali (persian) calendar. This package support parse from string, json and time.

Structures

There are three data structures for jalaali:

  • Jalaali jalaali date with current system time zone.
  • JalaaliTehran jalaali date with Asia/Tehran time zone.
  • JalaaliKabul jalaali date with Asia/Kabul time zone.
Methods

All structures has following methods for work with date.

IsNil

Check if date object is empty.

jDate.IsNil()
SetTime

Set date from standard time object.

jDate.SetTime(time.Now())
Parse

Parse date from jalaali date string.

Note: if date is invalid date object will be nil.

jDate.Parse("1400-01-02")
Time

Get current date as standard time. This function return nil if date is empty.

t := jDate.Time()
JTime

Get current date as jalaali date object. This function return nil if date is empty.

j := jDate.JTime()
UTC

Get current date as standard time object with utc timezone. This function return nil if date is empty.

utcT :=jDate.UTC()
Format

Format jalaali date. This function support standard go time formatting parameters.

f := jDate.Format("2006-01-02")

Helper Functions

TehranTz

Get timezone for Asia/Tehran.

KabulTz

Get timezone for Asia/Kabul.

Parse

Parse jalaali date string as time. This function use system timezone.

ParseForLocale

Parse jalaali date string as time for timezone.

New

Create new jalaali structure from time object. This function use system timezone.

NewTehran

Create new JalaaliTehran structure from time object. This function use Asia/Tehran timezone.

NewKabul

Create new JalaaliKabul structure from time object. This function use Asia/Kabul timezone.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KabulTz

func KabulTz() *time.Location

KabulTz get kabul time zone

func Parse

func Parse(str string) *time.Time

Parse parse jalaali date from string

this function return nil if invalid date passed

func ParseForLocale

func ParseForLocale(str string, loc *time.Location) *time.Time

ParseForLocale parse jalaali date from string for locale

this function return nil if invalid date passed

func TehranTz

func TehranTz() *time.Location

TehranTz get tehran time zone

Types

type Jalaali

type Jalaali struct {
	// contains filtered or unexported fields
}

Jalaali data structure

func New

func New(t time.Time) Jalaali

New create new jalaali date from time

this function use current time zone

func (Jalaali) Format

func (jTime Jalaali) Format(format string) string

Format format jalaali date using standard go time format

func (Jalaali) IsNil

func (jTime Jalaali) IsNil() bool

IsNil check if date is nil

func (Jalaali) JTime

func (jTime Jalaali) JTime() *ptime.Time

JTime get jalaali time

func (Jalaali) MarshalJSON

func (jTime Jalaali) MarshalJSON() ([]byte, error)

MarshalJSON get value for json

func (*Jalaali) Parse

func (jTime *Jalaali) Parse(str string)

Parse parse from jalaali string date

func (*Jalaali) SetTime

func (jTime *Jalaali) SetTime(t time.Time)

SetTime set jalaali date from time

func (Jalaali) String

func (jTime Jalaali) String() string

func (Jalaali) Time

func (jTime Jalaali) Time() *time.Time

Time get normal time

func (Jalaali) UTC

func (jTime Jalaali) UTC() *time.Time

UTC get normal time in UTC

func (*Jalaali) UnmarshalJSON

func (jTime *Jalaali) UnmarshalJSON(data []byte) error

UnmarshalJSON parse jalaali from bytes

type JalaaliKabul

type JalaaliKabul struct {
	Jalaali
}

JalaaliKabul jalaali date with kabul locale

func NewKabul

func NewKabul(t time.Time) JalaaliKabul

New create new jalaali date from time

this function use kabul time zone

func (*JalaaliKabul) Parse

func (kTime *JalaaliKabul) Parse(str string)

Parse parse from jalaali string date

func (*JalaaliKabul) SetTime

func (kTime *JalaaliKabul) SetTime(t time.Time)

SetTime set jalaali date from time

func (*JalaaliKabul) UnmarshalJSON

func (kTime *JalaaliKabul) UnmarshalJSON(data []byte) error

UnmarshalJSON parse jalaali from bytes

type JalaaliTehran

type JalaaliTehran struct {
	Jalaali
}

JalaaliTehran jalaali date with tehran locale

func NewTehran

func NewTehran(t time.Time) JalaaliTehran

New create new jalaali date from time

this function use tehran time zone

func (*JalaaliTehran) Parse

func (tTime *JalaaliTehran) Parse(str string)

Parse parse from jalaali string date

func (*JalaaliTehran) SetTime

func (tTime *JalaaliTehran) SetTime(t time.Time)

SetTime set jalaali date from time

func (*JalaaliTehran) UnmarshalJSON

func (tTime *JalaaliTehran) UnmarshalJSON(data []byte) error

UnmarshalJSON parse jalaali from bytes

Jump to

Keyboard shortcuts

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