Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 891 Bytes

README.md

File metadata and controls

36 lines (27 loc) · 891 Bytes

datetranslate

This package aims to translate format strings between 2 timestamp formats:

How to use it

package main

import (
    "fmt"
    "time"

    "github.com/observiq/ctimefmt"
    "github.com/pmalek-sumo/datetranslate"
)

func main() {
    dateFormat, err := datetranslate.SimpleDateFormat2Ctimefmt("yyyy-MM-dd HH:mm:ss.SSS")
    if err != nil {
        fmt.Printf("Couldn't translate provided format string: %v", err)
        return
    }

    out, err := ctimefmt.Format(dateFormat, time.Now())
    if err != nil {
        fmt.Printf("Couldn't format the time with ctimefmt: %v", err)
        return
    }

    fmt.Printf("The time is: %v", out)
}