All Projects → btubbs → datetime

btubbs / datetime

Licence: MIT license
A Go (golang) library for parsing most ISO8601 timestamps

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to datetime

Gostradamus
Gostradamus: Better DateTimes for Go 🕰️
Stars: ✭ 148 (+516.67%)
Mutual labels:  time, datetime
Dpicker
A framework-agnostic minimal date picker
Stars: ✭ 187 (+679.17%)
Mutual labels:  time, datetime
Time
Building a better date/time library for Swift
Stars: ✭ 1,983 (+8162.5%)
Mutual labels:  time, datetime
Delorean
Delorean: Time Travel Made Easy
Stars: ✭ 1,793 (+7370.83%)
Mutual labels:  time, datetime
iso8601
A fast ISO8601 date parser for Go
Stars: ✭ 122 (+408.33%)
Mutual labels:  time, datetime
Exceptionless.datetimeextensions
DateTimeRange, Business Day and various DateTime, DateTimeOffset, TimeSpan extension methods
Stars: ✭ 142 (+491.67%)
Mutual labels:  time, datetime
Date
A date and time library based on the C++11/14/17 <chrono> header
Stars: ✭ 2,389 (+9854.17%)
Mutual labels:  time, datetime
Calendar
📅 PHP Date & Time library that solves common problems in object oriented, immutable way.
Stars: ✭ 113 (+370.83%)
Mutual labels:  time, datetime
ptera
Ptera is DateTime library for Deno
Stars: ✭ 62 (+158.33%)
Mutual labels:  time, datetime
Jiffy
Jiffy is a Flutter (Android, IOS and Web) date time package inspired by momentjs for parsing, manipulating, querying and formatting dates
Stars: ✭ 238 (+891.67%)
Mutual labels:  time, datetime
Tail.datetime
A lightweight, translat- and configurable Open Source DateTime Picker, written in pure vanilla JavaScript!
Stars: ✭ 139 (+479.17%)
Mutual labels:  time, datetime
date-extractor
Extract dates from text
Stars: ✭ 58 (+141.67%)
Mutual labels:  time, datetime
Dateutil
Useful extensions to the standard Python datetime features
Stars: ✭ 1,706 (+7008.33%)
Mutual labels:  time, datetime
Date Picker
📅 Custom responsive date picker widget for Android, written in Kotlin.
Stars: ✭ 146 (+508.33%)
Mutual labels:  time, datetime
Human time
Ruby time and date comparisons for humans
Stars: ✭ 113 (+370.83%)
Mutual labels:  time, datetime
Eztime
ezTime — pronounced "Easy Time" — is a very easy to use Arduino time and date library that provides NTP network time lookups, extensive timezone support, formatted time and date strings, user events, millisecond precision and more.
Stars: ✭ 173 (+620.83%)
Mutual labels:  time, datetime
Dateparse
GoLang Parse many date strings without knowing format in advance.
Stars: ✭ 1,365 (+5587.5%)
Mutual labels:  time, datetime
Time Stamp
Get a formatted timestamp. Used in gulp, assemble, generate, and many others.
Stars: ✭ 104 (+333.33%)
Mutual labels:  time, datetime
Blitz
Android Library: Set self-updating string with relative time in TextView (e.g. 5 minutes ago)
Stars: ✭ 217 (+804.17%)
Mutual labels:  time, datetime
lit-date
Light-weight, faster datetime formatter for modern browsers.
Stars: ✭ 33 (+37.5%)
Mutual labels:  time, datetime

THIS REPO HAS MOVED

See the new home at https://github.com/nav-inc/datetime

datetime Build Status

datetime provides a Parse function for turning commonly-used ISO 8601 date/time formats into Golang time.Time variables. datetime.Parse takes two arguments:

  • the string you want to parse
  • the timezone location to be used if there's not one specified inside the string

Unlike Go's built-in RFC-3339 time format, this package automatically supports ISO 8601 date and time stamps with varying levels of granularity. Examples:

package main

import (
	"fmt"
	"time"

	"github.com/nav-inc/datetime"
)

func main() {
	// just a year, defaulting to the time.UTC timezone
	fmt.Println(datetime.Parse("2007", time.UTC)) // 2007-01-01 00:00:00 +0000 UTC <nil>

	// a year and a month, this time defaulting to time.Local timezone
	fmt.Println(datetime.Parse("2007-11", time.Local)) // 2007-11-01 00:00:00 -0600 MDT <nil>

	// a full date
	fmt.Println(datetime.Parse("2007-11-22", time.UTC)) // 2007-11-22 00:00:00 +0000 UTC <nil>

	// adding time
	fmt.Println(datetime.Parse("2007-11-22T12:30:22", time.UTC)) // 2007-11-22 12:30:22 -0700 MST <nil>

	// fractions of a second
	fmt.Println(datetime.Parse("2007-11-22T12:30:22.321", time.UTC)) // 2007-11-22 12:30:22.321 -0700 MST <nil>

	// omitting dashes and colons, as ISO 8601 allows
	fmt.Println(datetime.Parse("20071122T123022", time.UTC)) // 2007-11-22 12:30:22 -0700 MST <nil>

	// a timezone offset inside the input will override the default provided to datetime.Parse
	fmt.Println(datetime.Parse("2007-11-22T12:30:22+0800", time.Local)) // 2007-11-22 12:30:22 +0800 +0800 <nil>

	// adding separators to the offset too
	fmt.Println(datetime.Parse("2007-11-22T12:30:22+08:00", time.UTC)) // 2007-11-22 12:30:22 +0800 +08:00 <nil>

	// using a shorthand for UTC
	fmt.Println(datetime.Parse("2007-11-22T12:30:22Z", time.Local)) // 2007-11-22 12:30:22 +0000 UTC <nil>
}

DefaultUTC and DefaultLocal types are also provided. Used as struct fields, their Scan, Value, and UnmarshalJSON methods support easy parsing of ISO 8601 timestamps from external systems.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].