Sphire Mantis API Documentation

Sphire Mantis' API Documentation

View the Project on GitHub sphireinc/Mantis

Go Report Card Go Reference

date

import "github.com/sphireinc/mantis/date"

Index

func DaysInMonth

func DaysInMonth(year, month int) (int, error)

DaysInMonth returns the number of days in a given month and year

func GetWeekDayName

func GetWeekDayName(date *Date) string

GetWeekDayName returns the name of the week day (e.g. “Monday”, “Tuesday”) for a given Date object

func IsLeapYear

func IsLeapYear(year int) bool

IsLeapYear checks whether a given year is a leap year or not and returns a boolean value

func SubtractDates

func SubtractDates(date1, date2 *Date) (int64, time.Duration)

SubtractDates subtracts two Date objects and returns the duration between them in seconds or as a time.Duration object

func itos

func itos(intVal int) string

itos converts an int to a string, prepends zero if less than 10

type Date

Date struct

type Date struct {
    Year       int          `json:"year"`
    Month      time.Month   `json:"month"`
    Day        int          `json:"day"`
    Hour       int          `json:"hour"`
    Minute     int          `json:"minute"`
    Second     int          `json:"second"`
    Nanosecond int          `json:"nanosecond"`
    Unix       int64        `json:"unix"`
    WeekDay    time.Weekday `json:"week_day"`
    YearDay    int          `json:"year_day"`
}

func AddDays

func AddDays(date *Date, days int) *Date

AddDays adds a given number of days to a Date object and returns a new Date object

func CurrentTime

func CurrentTime() Date

CurrentTime is a Date factory

func NewDate

func NewDate(year, month, day, hour, minute, second, nanosecond int) (*Date, error)

NewDate creates a new Date object from a given year, month, day, hour, minute, second, and nanosecond

func ParseDate

func ParseDate(dateStr, format string) (*Date, error)

ParseDate parses a string representation of a date in a given format and returns a Date object

func StringToDate

func StringToDate(date string) (Date, error)

StringToDate takes a date string YYYY-MM-DD HH:MM:SS and returns a Date struct

func (*Date) DateToString

func (d *Date) DateToString(format string) (string, error)

DateToString converts a Date object to a string representation in a given format

func (*Date) String

func (d *Date) String() string

Generated by gomarkdoc