go-strftime: github.com/hhkbp2/go-strftime Index | Files

package strftime

import "github.com/hhkbp2/go-strftime"

Implementation of Python's strftime in Go

Example:

str, err := strftime.Format("%Y/%m/%d", time.Now()) // 2012/12/07

Directives:

%a - Locale’s abbreviated weekday name
%A - Locale’s full weekday name
%b - Locale’s abbreviated month name
%B - Locale’s full month name
%c - Locale’s appropriate date and time representation
%d - Day of the month as a decimal number [01,31]
%H - Hour (24-hour clock) as a decimal number [00,23]
%I - Hour (12-hour clock) as a decimal number [01,12]
%j - Day of year
%m - Month as a decimal number [01,12]
%M - Minute as a decimal number [00,59]
%p - Locale’s equivalent of either AM or PM
%S - Second as a decimal number [00,61]
%U - Week number of the year
%w - Weekday as a decimal number
%W - Week number of the year
%x - Locale’s appropriate date representation
%X - Locale’s appropriate time representation
%y - Year without century as a decimal number [00,99]
%Y - Year with century as a decimal number
%Z - Time zone name (no characters if no time zone exists)

Note that %c returns RFC1123 which is a bit different from what Python does

Index

Package Files

strftime.go

Constants

const (
    WEEK = time.Hour * 24 * 7
)

func Format Uses

func Format(format string, t time.Time) string

Format return string with % directives expanded. Will return error on unknown directive.

func FormatTo Uses

func FormatTo(w io.Writer, format string, t time.Time) (n int, err error)

type FormatFunc Uses

type FormatFunc func(t time.Time) string

type Formatter Uses

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

func NewFormatter Uses

func NewFormatter(format string) *Formatter

func (*Formatter) Format Uses

func (self *Formatter) Format(t time.Time) string

func (*Formatter) FormatTo Uses

func (self *Formatter) FormatTo(w io.Writer, t time.Time) (n int, err error)

Package strftime imports 5 packages (graph) and is imported by 2 packages. Updated 2016-07-20. Refresh now. Tools for package owners.