dateutils

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dateutils provides functions to work with dates.

Index

Examples

Constants

View Source
const Iso8601DateFormat = "2006-01-02"

Iso8601DateFormat is the ISO 8601 date format without time.

Variables

This section is empty.

Functions

func GetDateFromCrossrefParts added in v0.2.8

func GetDateFromCrossrefParts(strParts ...string) string

GetDateFromCrossrefParts returns a date string from Crossref XML date parts

func GetDateFromDateParts

func GetDateFromDateParts(dateAsParts [][]int) string

GetDateFromDateParts returns a date string from date parts

func GetDateFromParts

func GetDateFromParts(parts ...int) string

GetDateFromParts returns a date string from parts

func GetDateFromUnixTimestamp

func GetDateFromUnixTimestamp(timestamp int64) string

GetDateFromUnixTimestamp returns a date string from a Unix timestamp

Example
package main

import (
	"fmt"

	"github.com/front-matter/commonmeta/dateutils"
)

func main() {
	s := dateutils.GetDateFromUnixTimestamp(1611312000)
	fmt.Println(s)
}
Output:
2021-01-22

func GetDateParts added in v0.2.4

func GetDateParts(iso8601Time string) map[string][][]int

GetDateParts return date parts from an ISO 8601 date string

Example
package main

import (
	"fmt"

	"github.com/front-matter/commonmeta/dateutils"
)

func main() {
	m := dateutils.GetDateParts("2023-12-06")
	fmt.Println(m)
}
Output:
map[date-parts:[[2023 12 6]]]

func ParseDate added in v0.2.8

func ParseDate(date string) string

ParseDate parses date strings in various formats and returns a date string in ISO 8601 format

Types

This section is empty.

Jump to

Keyboard shortcuts

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