gotime

package module
v0.0.0-...-80125f1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2015 License: MIT Imports: 2 Imported by: 0

README

#GoTime

GoTime is a time toolkit for golang

GoDoc

#Usage:

Check main file in test folder or follow this code:

Import

import "github.com/aligoren/gotime"

Current Type Functions:

TimeNow() => Now Time
DayNow() => Day Now
WeekNow() => Weekday Now
PreviousDay() => Previous Day (DayNow -1)
NextDay() => Next Day (DayNow + 1)
DayAgo() => X Days Ago (3 Day Ago)
DayLater() => X Days Later (5 Day Later)
MonthNow() => Month Now
MonthAgo() => X Months Ago
MonthLater() => X Months Later
YearNow() => Current Year
YearAgo() => X Years Ago (3 Years Ago: 2012)
YearLater() => X Years Later (3 Years Later: 2018)
DayOfWeek() => X Day of Week (Day of Week 3th: Wednesday)
DayOfYear() => Current Now: 134th Day of Year

Wait Functions:

WaitMicro() => Wait for X Microseconds
WaitNS() => Wait for X Nanoseconds
WaitMS() => Wait for X Milliseconds
WaitSec() => Wait for X Seconds
WaitMin() => Wait for X Minutes
WaitHour() => Wait for X Hours

#Sample Usage:

package main

import (
    "fmt"
    "github.com/aligoren/gotime"
)

func main() {
    
    s := gotime.Now{}

    fmt.Println(s.TimeNow()) // Now Time 14:55:29 (My current time)
    fmt.Println(s.DayNow()) // Day Now (14th)
    fmt.Println(s.WeekNow()) // Weekday (Thursday)
    fmt.Println(s.PreviousDay()) // Wednesday May 13
    fmt.Println(s.NextDay()) // Friday May 15
    fmt.Println(s.DayAgo(3)) // 3 Days Ago: Monday
    fmt.Println(s.DayLater(2)) // 2 Days Later: Saturday
    fmt.Println(s.MonthNow()) // Now Month (May)
    fmt.Println(s.MonthAgo(3)) // 3 Months Ago: February
    fmt.Println(s.MonthLater(3)) // 3 Months Later: August
    fmt.Println(s.YearNow()) // Year Now: 2015
    fmt.Println(s.YearAgo(5)) // 5 Years Ago: 2010
    fmt.Println(s.YearLater(5)) // 5 Years Later: 2020
    fmt.Println(s.DayOfWeek(3)) // Day of Week 3th: Wednesday
    fmt.Println(s.DayOfYear()) // Day of Year 134th
    s.WaitSec(3) // Wait for 3 Seconds
    s.WaitMS(300) // Wait for 300 Milliseconds
    s.WaitMicro(5000) // Wait for 5000 Microsecond
    s.WaitNS(3000) // Wait for 3000 Nanoseconds
    s.WaitMin(3) // Wait for 3 Minutes
    s.WaitHour(5) // Wait for 5 Hours
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Now

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

func (Now) DayAgo

func (n Now) DayAgo(ago time.Weekday) time.Weekday

func (Now) DayLater

func (n Now) DayLater(later time.Weekday) time.Weekday

func (Now) DayNow

func (n Now) DayNow() int

func (Now) DayOfWeek

func (n Now) DayOfWeek(wn time.Weekday) time.Weekday

func (Now) DayOfYear

func (n Now) DayOfYear() int

func (Now) MonthAgo

func (n Now) MonthAgo(ago time.Duration) string

func (Now) MonthLater

func (n Now) MonthLater(later time.Duration) string

func (Now) MonthNow

func (n Now) MonthNow() time.Month

func (Now) NextDay

func (n Now) NextDay() string

func (Now) PreviousDay

func (n Now) PreviousDay() string

func (Now) TimeNow

func (n Now) TimeNow() string

func (Now) WaitHour

func (n Now) WaitHour(wait time.Duration)

func (Now) WaitMS

func (n Now) WaitMS(wait time.Duration)

func (Now) WaitMicro

func (n Now) WaitMicro(wait time.Duration)

func (Now) WaitMin

func (n Now) WaitMin(wait time.Duration)

func (Now) WaitNS

func (n Now) WaitNS(wait time.Duration)

func (Now) WaitSec

func (n Now) WaitSec(wait time.Duration)

func (Now) WeekNow

func (n Now) WeekNow() time.Weekday

func (Now) YearAgo

func (n Now) YearAgo(ago int) int

func (Now) YearLater

func (n Now) YearLater(later int) int

func (Now) YearNow

func (n Now) YearNow() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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