tuesday

package module
Version: v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2017 License: MIT Imports: 6 Imported by: 14

README

Tuesday: Ruby-Compatible Strftime for Go

This package provides a function Strftime that is compatible with Ruby's Time.strftime.

It provides additional flags and conversions beyond C stdlib-like strftimes:

  • padding flags, e.g. %-m, %_m, %0e
  • case change flags, e.g. %^A, %#b
  • field widths: %03e, %3N, %9N
  • Ruby-specific conversions such as %s, %N, %:z, %::z

It was developed for use with in Liquid and Gojekyll.

Install

go get gopkg.in/osteele/tuesday.v1 # latest snapshot

go get -u github.com/osteele/tuesday # development version

References

License

MIT License

Documentation

Overview

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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Strftime

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.

Example (Flags)
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
Example (Timezone)
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

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

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