Documentation ¶
Overview ¶
Package week provides a simple data type representing a week date as defined by ISO 8601.
Index ¶
- type NullWeek
- func (n NullWeek) IsZero() bool
- func (n NullWeek) MarshalJSON() ([]byte, error)
- func (n NullWeek) MarshalText() ([]byte, error)
- func (n NullWeek) Ptr() *Week
- func (n *NullWeek) Scan(value interface{}) error
- func (n *NullWeek) UnmarshalJSON(data []byte) error
- func (n *NullWeek) UnmarshalText(text []byte) error
- func (n NullWeek) Value() (driver.Value, error)
- type Week
- func (w *Week) Add(weeks int) (Week, error)
- func (w *Week) After(u Week) bool
- func (w *Week) Before(u Week) bool
- func (w *Week) Equal(u Week) bool
- func (w Week) MarshalJSON() ([]byte, error)
- func (w Week) MarshalText() ([]byte, error)
- func (w *Week) Next() (Week, error)
- func (w *Week) Previous() (Week, error)
- func (w *Week) Scan(src interface{}) error
- func (w Week) String() string
- func (w *Week) Sub(u Week) int
- func (w *Week) Time(weekday time.Weekday) time.Time
- func (w *Week) UnmarshalJSON(data []byte) error
- func (w *Week) UnmarshalText(data []byte) error
- func (w Week) Value() (driver.Value, error)
- func (w *Week) Week() int
- func (w *Week) Year() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NullWeek ¶
NullWeek is a nullable Week representation.
func NewNullWeek ¶
NewNullWeek creates a new NullWeek.
func NullWeekFrom ¶
NullWeekFrom creates a new NullWeek that will always be valid.
func NullWeekFromPtr ¶
NullWeekFromPtr creates a new NullWeek that may be null if week is nil.
func (NullWeek) MarshalJSON ¶
MarshalJSON implements the json Marshaler interface.
func (NullWeek) MarshalText ¶
MarshalText implements the encoding TextMarshaler interface.
func (NullWeek) Ptr ¶
Ptr returns a pointer to this NullWeek's value, or a nil pointer it it is invalid.
func (*NullWeek) UnmarshalJSON ¶
UnmarshalJSON implements the json Unmarshaler interface.
func (*NullWeek) UnmarshalText ¶
UnmarshalText implements the encoding TextUnmarshaler interface.
type Week ¶
type Week struct {
// contains filtered or unexported fields
}
Week represents a week date as defined by ISO 8601. Week can be marshaled to and unmarshaled from numerous formats such as plain text or json.
func (*Week) Add ¶ added in v0.0.5
Add calculates and returns a week that is the given positive distance (number of weeks) from the current week
func (*Week) Equal ¶ added in v0.0.6
Equal reports whether w and u are the same week of the same year
func (Week) MarshalJSON ¶
MarshalJSON implements json.Marshaler for Week.
func (Week) MarshalText ¶
MarshalText implements TextMarshaler for Week.
func (*Week) Next ¶
Next calculates and returns the next week. If the next week is invalid (year > 9999) the function returns an error.
func (*Week) Previous ¶
Previous calculates and returns the previous week. If the previous week is invalid (year < 0) the function returns an error.
func (*Week) Sub ¶ added in v0.0.5
Sub calculates the positive difference between w and u (w-u) in number of weeks
func (*Week) Time ¶ added in v0.0.3
Time converts a week to a time.Time object which represents the midnight of the provided weekday.
func (*Week) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler for Week.
func (*Week) UnmarshalText ¶
UnmarshalText implements TextUnmarshaler for Week.