xtime

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 1 Imported by: 0

README

xtime

Date/time helpers and small utilities for formatting and layout translation.

 

xtime aggregates convenience functions to simplify common date/time operations and formatting tasks across CLI tools and services. The package intends to collect a small set of helpers that reduce boilerplate when working with Go's time package and custom layout conventions.


Purpose

The goal of xtime is to provide lightweight helpers for converting and managing datetime layout strings, parsing convenience, and other small tools that are commonly useful in CLI utilities and application scaffolding.

At the moment the package exposes a layout translation helper that maps a universal format string (e.g. YYYY-MM-DD HH:mm:ss.SSS a) into Go's native reference time layout.


Installation

Use go get to add the package to your module:

  go get github.com/AeonDigital/Go-Core/xtime@latest

Import it in your code:

import "github.com/AeonDigital/Go-Core/xtime"

Basic usage

Translate a universal datetime layout into Go's layout string:

universal := "YYYY-MM-DD HH:mm:ss.SSS a"
goLayout := xtime.FormatGenericDateTimeToGolangLayout(universal)
// goLayout == "2006-01-02 15:04:05.000 pm"

now := time.Now().In(location)
formatted := now.Format(goLayout)

This helper is useful when accepting user-facing formatting patterns or supporting configuration that uses common, readable datetime tokens.


Supported APIs

Currently the package exposes:

  • xtime.FormatGenericDateTimeToGolangLayout(universalLayout string) string

This function maps common tokens such as YYYY, MM, DD, HH, mm, ss, SSS, a/A, and timezone tokens (Z, ZZ) into Go's reference time layout tokens.


External dependencies

xtime depends only on the Go standard library (strings). No third-party packages are required.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatGenericDateTimeToGolangLayout

func FormatGenericDateTimeToGolangLayout(universalLayout string) string

FormatGenericDateTimeToGolangLayout converts a universal date/time format string (e.g., "YYYY-MM-DD HH:mm:ss.SSS a") into Go's native reference time layout. It maps standard placeholders for year, month, day, hours, minutes, seconds, milliseconds, meridiem indicators (AM/PM), and timezones to their corresponding Go time layout tokens. Returns the translated string ready to be used with Go's time parsing and formatting functions.

Types

This section is empty.

Jump to

Keyboard shortcuts

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