strftime

package module
v0.0.0-...-016cde6 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2018 License: MIT Imports: 6 Imported by: 7

README

Build Status Coverage Status Go Report Card GoDoc

strftime

C99-compatible strftime formatter for use with Go time.Time instances.

See strftime for available conversion specifiers. Specific locale specifiers are not yet supported.

Documentation

Overview

Package strftime provides a C99-compatible strftime formatter for use with Go time.Time instances.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(t *time.Time, f string) string

Format accepts a Time pointer and a C99-compatible strftime format string and returns the formatted result. If the Time pointer is nil, the current time is used.

See http://en.cppreference.com/w/c/chrono/strftime for available conversion specifiers. Specific locale specifiers are not yet supported.

Example
t := time.Date(2018, time.July, 9, 13, 14, 15, 0, time.UTC)

fmt.Println(Format(&t, "%c"))
fmt.Println(Format(&t, "%%Y-%%m-%%d -> %Y-%m-%d"))
fmt.Println(Format(&t, "%A is day number %w of the week."))
fmt.Println(Format(&t, "Last century was%n the %Cth century."))
fmt.Println(Format(&t, "Time zone: %Z"))
Output:

Mon Jul  9 13:14:15 2018
%Y-%m-%d -> 2018-07-09
Monday is day number 1 of the week.
Last century was
 the 20th century.
Time zone: UTC

Types

This section is empty.

Jump to

Keyboard shortcuts

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