rbstrftime.v1: gopkg.in/osteele/rbstrftime.v1 Index | Examples | Files

package tuesday

import "gopkg.in/osteele/rbstrftime.v1"

Package tuesday implements a Strftime function that is compatible with Ruby's Time.strftime.

Index

Examples

Package Files

strftime.go

func Strftime Uses

func Strftime(format string, t time.Time) (string, error)

Strftime is compatible with Ruby's Time.strftime.

See https://ruby-doc.org/core-2.4.1/Time.html#method-i-strftime

Strftime returns an error for compatibility with other formatting functions and for future compatibility, but in the current implementation this error is always nil.

Code:

t, _ := time.Parse(time.RFC822, "10 Jul 17 18:45 EDT")
s, _ := Strftime("%B %^B %m %_m %-m %6Y", t)
fmt.Println(s)

Output:

July JULY 07  7 7 002017

Code:

t, _ := time.Parse(time.RFC822, "10 Jul 17 18:45 EDT")
s, _ := Strftime("%Z %z %:z %::z", t)
fmt.Println(s)

Output:

EDT -0400 -04:00 -04:00:00

Package tuesday imports 6 packages (graph). Updated 2017-10-22. Refresh now. Tools for package owners.