Help us shape the future of Go! Take the 2026 Go Developer Survey

goparsetime

package module
v0.0.0-...-ea17b0a Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

README

goparsetime

Go wrapper for parsetime.c from UNIX "at" command.

Parse date strings and return a time.Time

Usage

Parse basic timestring

    t, err := goparsetime.Parsetime("10:00 AM UTC Oct 21 2015")
    fmt.Printf("%v\n", t.UTC()) // 2015-10-21 10:00:00 +0000 UTC

Relative date math

    t, err = goparsetime.Parsetime("10:00 AM UTC Oct 21 2015 + 5 days")
    fmt.Printf("%v\n", t.UTC()) // 2015-10-26 10:00:00 +0000 UTC

Relative math to current time

    now := time.Now() // 2015-10-21 19:45:18.035108719 +0000 UTC
    t, err = goparsetime.Parsetime("now - 2 weeks + 3 hours")
    fmt.Printf("%v\n", t.UTC()) // 2015-10-07 22:45:18 +0000 UTC

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parsetime

func Parsetime(t string) (time.Time, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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