GoLang Parse many date strings without knowing format in advance.

Overview

Go Date Parser

Parse many date strings without knowing format in advance. Uses a scanner to read bytes and use a state machine to find format. Much faster than shotgun based parse methods. See bench_test.go for performance comparison.

Code Coverage GoDoc Build Status Go ReportCard

MM/DD/YYYY VS DD/MM/YYYY Right now this uses mm/dd/yyyy WHEN ambiguous if this is not desired behavior, use ParseStrict which will fail on ambiguous date strings.

Timezones The location your server is configured affects the results! See example or https://play.golang.org/p/IDHRalIyXh and last paragraph here https://golang.org/pkg/time/#Parse.

// Normal parse.  Equivalent Timezone rules as time.Parse()
t, err := dateparse.ParseAny("3/1/2014")

// Parse Strict, error on ambigous mm/dd vs dd/mm dates
t, err := dateparse.ParseStrict("3/1/2014")
> returns error 

// Return a string that represents the layout to parse the given date-time.
layout, err := dateparse.ParseFormat("May 8, 2009 5:57:51 PM")
> "Jan 2, 2006 3:04:05 PM"

cli tool for testing dateformats

Date Parse CLI

Extended example

https://github.com/araddon/dateparse/blob/master/example/main.go

package main

import (
	"flag"
	"fmt"
	"time"

	"github.com/scylladb/termtables"
	"github.com/araddon/dateparse"
)

var examples = []string{
	"May 8, 2009 5:57:51 PM",
	"oct 7, 1970",
	"oct 7, '70",
	"oct. 7, 1970",
	"oct. 7, 70",
	"Mon Jan  2 15:04:05 2006",
	"Mon Jan  2 15:04:05 MST 2006",
	"Mon Jan 02 15:04:05 -0700 2006",
	"Monday, 02-Jan-06 15:04:05 MST",
	"Mon, 02 Jan 2006 15:04:05 MST",
	"Tue, 11 Jul 2017 16:28:13 +0200 (CEST)",
	"Mon, 02 Jan 2006 15:04:05 -0700",
	"Thu, 4 Jan 2018 17:53:36 +0000",
	"Mon 30 Sep 2018 09:09:09 PM UTC",
	"Mon Aug 10 15:44:11 UTC+0100 2015",
	"Thu, 4 Jan 2018 17:53:36 +0000",
	"Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time)",
	"September 17, 2012 10:09am",
	"September 17, 2012 at 10:09am PST-08",
	"September 17, 2012, 10:10:09",
	"October 7, 1970",
	"October 7th, 1970",
	"12 Feb 2006, 19:17",
	"12 Feb 2006 19:17",
	"7 oct 70",
	"7 oct 1970",
	"03 February 2013",
	"1 July 2013",
	"2013-Feb-03",
	//   mm/dd/yy
	"3/31/2014",
	"03/31/2014",
	"08/21/71",
	"8/1/71",
	"4/8/2014 22:05",
	"04/08/2014 22:05",
	"4/8/14 22:05",
	"04/2/2014 03:00:51",
	"8/8/1965 12:00:00 AM",
	"8/8/1965 01:00:01 PM",
	"8/8/1965 01:00 PM",
	"8/8/1965 1:00 PM",
	"8/8/1965 12:00 AM",
	"4/02/2014 03:00:51",
	"03/19/2012 10:11:59",
	"03/19/2012 10:11:59.3186369",
	// yyyy/mm/dd
	"2014/3/31",
	"2014/03/31",
	"2014/4/8 22:05",
	"2014/04/08 22:05",
	"2014/04/2 03:00:51",
	"2014/4/02 03:00:51",
	"2012/03/19 10:11:59",
	"2012/03/19 10:11:59.3186369",
	// yyyy:mm:dd
	"2014:3:31",
	"2014:03:31",
	"2014:4:8 22:05",
	"2014:04:08 22:05",
	"2014:04:2 03:00:51",
	"2014:4:02 03:00:51",
	"2012:03:19 10:11:59",
	"2012:03:19 10:11:59.3186369",
	// Chinese
	"2014年04月08日",
	//   yyyy-mm-ddThh
	"2006-01-02T15:04:05+0000",
	"2009-08-12T22:15:09-07:00",
	"2009-08-12T22:15:09",
	"2009-08-12T22:15:09Z",
	//   yyyy-mm-dd hh:mm:ss
	"2014-04-26 17:24:37.3186369",
	"2012-08-03 18:31:59.257000000",
	"2014-04-26 17:24:37.123",
	"2013-04-01 22:43",
	"2013-04-01 22:43:22",
	"2014-12-16 06:20:00 UTC",
	"2014-12-16 06:20:00 GMT",
	"2014-04-26 05:24:37 PM",
	"2014-04-26 13:13:43 +0800",
	"2014-04-26 13:13:43 +0800 +08",
	"2014-04-26 13:13:44 +09:00",
	"2012-08-03 18:31:59.257000000 +0000 UTC",
	"2015-09-30 18:48:56.35272715 +0000 UTC",
	"2015-02-18 00:12:00 +0000 GMT",
	"2015-02-18 00:12:00 +0000 UTC",
	"2015-02-08 03:02:00 +0300 MSK m=+0.000000001",
	"2015-02-08 03:02:00.001 +0300 MSK m=+0.000000001",
	"2017-07-19 03:21:51+00:00",
	"2014-04-26",
	"2014-04",
	"2014",
	"2014-05-11 08:20:13,787",
	// mm.dd.yy
	"3.31.2014",
	"03.31.2014",
	"08.21.71",
	"2014.03",
	"2014.03.30",
	//  yyyymmdd and similar
	"20140601",
	"20140722105203",
	// unix seconds, ms, micro, nano
	"1332151919",
	"1384216367189",
	"1384216367111222",
	"1384216367111222333",
}

var (
	timezone = ""
)

func main() {
	flag.StringVar(&timezone, "timezone", "UTC", "Timezone aka `America/Los_Angeles` formatted time-zone")
	flag.Parse()

	if timezone != "" {
		// NOTE:  This is very, very important to understand
		// time-parsing in go
		loc, err := time.LoadLocation(timezone)
		if err != nil {
			panic(err.Error())
		}
		time.Local = loc
	}

	table := termtables.CreateTable()

	table.AddHeaders("Input", "Parsed, and Output as %v")
	for _, dateExample := range examples {
		t, err := dateparse.ParseLocal(dateExample)
		if err != nil {
			panic(err.Error())
		}
		table.AddRow(dateExample, fmt.Sprintf("%v", t))
	}
	fmt.Println(table.Render())
}

/*
+-------------------------------------------------------+-----------------------------------------+
| Input                                                 | Parsed, and Output as %v                |
+-------------------------------------------------------+-----------------------------------------+
| May 8, 2009 5:57:51 PM                                | 2009-05-08 17:57:51 +0000 UTC           |
| oct 7, 1970                                           | 1970-10-07 00:00:00 +0000 UTC           |
| oct 7, '70                                            | 1970-10-07 00:00:00 +0000 UTC           |
| oct. 7, 1970                                          | 1970-10-07 00:00:00 +0000 UTC           |
| oct. 7, 70                                            | 1970-10-07 00:00:00 +0000 UTC           |
| Mon Jan  2 15:04:05 2006                              | 2006-01-02 15:04:05 +0000 UTC           |
| Mon Jan  2 15:04:05 MST 2006                          | 2006-01-02 15:04:05 +0000 MST           |
| Mon Jan 02 15:04:05 -0700 2006                        | 2006-01-02 15:04:05 -0700 -0700         |
| Monday, 02-Jan-06 15:04:05 MST                        | 2006-01-02 15:04:05 +0000 MST           |
| Mon, 02 Jan 2006 15:04:05 MST                         | 2006-01-02 15:04:05 +0000 MST           |
| Tue, 11 Jul 2017 16:28:13 +0200 (CEST)                | 2017-07-11 16:28:13 +0200 +0200         |
| Mon, 02 Jan 2006 15:04:05 -0700                       | 2006-01-02 15:04:05 -0700 -0700         |
| Mon 30 Sep 2018 09:09:09 PM UTC                       | 2018-09-30 21:09:09 +0000 UTC           |
| Mon Aug 10 15:44:11 UTC+0100 2015                     | 2015-08-10 15:44:11 +0000 UTC           |
| Thu, 4 Jan 2018 17:53:36 +0000                        | 2018-01-04 17:53:36 +0000 UTC           |
| Fri Jul 03 2015 18:04:07 GMT+0100 (GMT Daylight Time) | 2015-07-03 18:04:07 +0100 GMT           |
| September 17, 2012 10:09am                            | 2012-09-17 10:09:00 +0000 UTC           |
| September 17, 2012 at 10:09am PST-08                  | 2012-09-17 10:09:00 -0800 PST           |
| September 17, 2012, 10:10:09                          | 2012-09-17 10:10:09 +0000 UTC           |
| October 7, 1970                                       | 1970-10-07 00:00:00 +0000 UTC           |
| October 7th, 1970                                     | 1970-10-07 00:00:00 +0000 UTC           |
| 12 Feb 2006, 19:17                                    | 2006-02-12 19:17:00 +0000 UTC           |
| 12 Feb 2006 19:17                                     | 2006-02-12 19:17:00 +0000 UTC           |
| 7 oct 70                                              | 1970-10-07 00:00:00 +0000 UTC           |
| 7 oct 1970                                            | 1970-10-07 00:00:00 +0000 UTC           |
| 03 February 2013                                      | 2013-02-03 00:00:00 +0000 UTC           |
| 1 July 2013                                           | 2013-07-01 00:00:00 +0000 UTC           |
| 2013-Feb-03                                           | 2013-02-03 00:00:00 +0000 UTC           |
| 3/31/2014                                             | 2014-03-31 00:00:00 +0000 UTC           |
| 03/31/2014                                            | 2014-03-31 00:00:00 +0000 UTC           |
| 08/21/71                                              | 1971-08-21 00:00:00 +0000 UTC           |
| 8/1/71                                                | 1971-08-01 00:00:00 +0000 UTC           |
| 4/8/2014 22:05                                        | 2014-04-08 22:05:00 +0000 UTC           |
| 04/08/2014 22:05                                      | 2014-04-08 22:05:00 +0000 UTC           |
| 4/8/14 22:05                                          | 2014-04-08 22:05:00 +0000 UTC           |
| 04/2/2014 03:00:51                                    | 2014-04-02 03:00:51 +0000 UTC           |
| 8/8/1965 12:00:00 AM                                  | 1965-08-08 00:00:00 +0000 UTC           |
| 8/8/1965 01:00:01 PM                                  | 1965-08-08 13:00:01 +0000 UTC           |
| 8/8/1965 01:00 PM                                     | 1965-08-08 13:00:00 +0000 UTC           |
| 8/8/1965 1:00 PM                                      | 1965-08-08 13:00:00 +0000 UTC           |
| 8/8/1965 12:00 AM                                     | 1965-08-08 00:00:00 +0000 UTC           |
| 4/02/2014 03:00:51                                    | 2014-04-02 03:00:51 +0000 UTC           |
| 03/19/2012 10:11:59                                   | 2012-03-19 10:11:59 +0000 UTC           |
| 03/19/2012 10:11:59.3186369                           | 2012-03-19 10:11:59.3186369 +0000 UTC   |
| 2014/3/31                                             | 2014-03-31 00:00:00 +0000 UTC           |
| 2014/03/31                                            | 2014-03-31 00:00:00 +0000 UTC           |
| 2014/4/8 22:05                                        | 2014-04-08 22:05:00 +0000 UTC           |
| 2014/04/08 22:05                                      | 2014-04-08 22:05:00 +0000 UTC           |
| 2014/04/2 03:00:51                                    | 2014-04-02 03:00:51 +0000 UTC           |
| 2014/4/02 03:00:51                                    | 2014-04-02 03:00:51 +0000 UTC           |
| 2012/03/19 10:11:59                                   | 2012-03-19 10:11:59 +0000 UTC           |
| 2012/03/19 10:11:59.3186369                           | 2012-03-19 10:11:59.3186369 +0000 UTC   |
| 2014年04月08日                                        | 2014-04-08 00:00:00 +0000 UTC           |
| 2006-01-02T15:04:05+0000                              | 2006-01-02 15:04:05 +0000 UTC           |
| 2009-08-12T22:15:09-07:00                             | 2009-08-12 22:15:09 -0700 -0700         |
| 2009-08-12T22:15:09                                   | 2009-08-12 22:15:09 +0000 UTC           |
| 2009-08-12T22:15:09Z                                  | 2009-08-12 22:15:09 +0000 UTC           |
| 2014-04-26 17:24:37.3186369                           | 2014-04-26 17:24:37.3186369 +0000 UTC   |
| 2012-08-03 18:31:59.257000000                         | 2012-08-03 18:31:59.257 +0000 UTC       |
| 2014-04-26 17:24:37.123                               | 2014-04-26 17:24:37.123 +0000 UTC       |
| 2013-04-01 22:43                                      | 2013-04-01 22:43:00 +0000 UTC           |
| 2013-04-01 22:43:22                                   | 2013-04-01 22:43:22 +0000 UTC           |
| 2014-12-16 06:20:00 UTC                               | 2014-12-16 06:20:00 +0000 UTC           |
| 2014-12-16 06:20:00 GMT                               | 2014-12-16 06:20:00 +0000 UTC           |
| 2014-04-26 05:24:37 PM                                | 2014-04-26 17:24:37 +0000 UTC           |
| 2014-04-26 13:13:43 +0800                             | 2014-04-26 13:13:43 +0800 +0800         |
| 2014-04-26 13:13:43 +0800 +08                         | 2014-04-26 13:13:43 +0800 +0800         |
| 2014-04-26 13:13:44 +09:00                            | 2014-04-26 13:13:44 +0900 +0900         |
| 2012-08-03 18:31:59.257000000 +0000 UTC               | 2012-08-03 18:31:59.257 +0000 UTC       |
| 2015-09-30 18:48:56.35272715 +0000 UTC                | 2015-09-30 18:48:56.35272715 +0000 UTC  |
| 2015-02-18 00:12:00 +0000 GMT                         | 2015-02-18 00:12:00 +0000 UTC           |
| 2015-02-18 00:12:00 +0000 UTC                         | 2015-02-18 00:12:00 +0000 UTC           |
| 2015-02-08 03:02:00 +0300 MSK m=+0.000000001          | 2015-02-08 03:02:00 +0300 +0300         |
| 2015-02-08 03:02:00.001 +0300 MSK m=+0.000000001      | 2015-02-08 03:02:00.001 +0300 +0300     |
| 2017-07-19 03:21:51+00:00                             | 2017-07-19 03:21:51 +0000 UTC           |
| 2014-04-26                                            | 2014-04-26 00:00:00 +0000 UTC           |
| 2014-04                                               | 2014-04-01 00:00:00 +0000 UTC           |
| 2014                                                  | 2014-01-01 00:00:00 +0000 UTC           |
| 2014-05-11 08:20:13,787                               | 2014-05-11 08:20:13.787 +0000 UTC       |
| 3.31.2014                                             | 2014-03-31 00:00:00 +0000 UTC           |
| 03.31.2014                                            | 2014-03-31 00:00:00 +0000 UTC           |
| 08.21.71                                              | 1971-08-21 00:00:00 +0000 UTC           |
| 2014.03                                               | 2014-03-01 00:00:00 +0000 UTC           |
| 2014.03.30                                            | 2014-03-30 00:00:00 +0000 UTC           |
| 20140601                                              | 2014-06-01 00:00:00 +0000 UTC           |
| 20140722105203                                        | 2014-07-22 10:52:03 +0000 UTC           |
| 1332151919                                            | 2012-03-19 10:11:59 +0000 UTC           |
| 1384216367189                                         | 2013-11-12 00:32:47.189 +0000 UTC       |
| 1384216367111222                                      | 2013-11-12 00:32:47.111222 +0000 UTC    |
| 1384216367111222333                                   | 2013-11-12 00:32:47.111222333 +0000 UTC |
+-------------------------------------------------------+-----------------------------------------+
*/
Comments
  • Options framework to allow more control over parsing

    Options framework to allow more control over parsing

    This PR creates a framework for creating and applying arbitrary options without breaking changes. It follows the pattern used in github.com/gorilla/handlers. Options are created by implementing the ParserOption interface. They are then passed in a spread to existing parsing functions. The options are passed down into the parser constructor, where they are then applied on the parser. Through the excellent architecture already present in this package, the changes to accomplish this are straightforward.

    The first options to implement the ParserOption interface are PreferMonthFirst and RetryAmbiguousDateWithSwap.

    PreferMonthFirst exposes parser.preferMonthFirst, and the code handling the false case was added by #88.

    RetryAmbiguousDateWithSwap adds a new parser field, parser.retryAmbiguousDateWithSwap, allowing parsing not to fail when the month is not actually ambiguous because if it were swapped with the day it would be outside the range of valid month values. It does this by checking if the month was ambiguous; if so, then trying to parse, and rebuilding the parser with the opposite preferMonthFirst value and disabling retryAmbiguousDateWithSwap. The code of the logic behind the option was added by #88, and this PR places its implementation in a much tighter scope while also exposing it as a ParserOption.

    opened by troyspencer 13
  • Local time

    Local time

    Is there a way to convert a string like this Thu, 13 Jul 2017 08:16:43 -0700 in my local time ?

    After parsing I obtain an time.Time object 2017-07-13 08:16:43 -0700 -0700 but seem to be 9 hours back

    opened by matiux 10
  • Could not find time offset

    Could not find time offset

    Hi,

    if we will do something like: a := time.Now().Local().Add(time.Hour*time.Duration(0) + time.Minute*time.Duration(30) + time.Second*time.Duration(0))

    (it's just offset for 30 mins from now), we will get: 2018-02-11 15:55:38.194708 +0300 MSK

    in a variable, for example. Let's place this value like a string type: a := "2018-02-11 15:55:38.194708 +0300 MSK"

    and try to use ParseLocal() for this string variable: t, _ := dateparse.ParseLocal(a)

    we will get 0001-01-01 00:00:00 +0000 UTC.

    opened by johndark 6
  • Can't parse golang default format

    Can't parse golang default format

    What am I doing wrong?

    package main
    
    import (
    	"fmt"
    	"github.com/araddon/dateparse"
    )
    
    func main() {
    	a := "2018-06-29 19:09:57.77297118 +0300 +03" // result of time.Now().String()
    
    	fmt.Println(a)
    	t, err := dateparse.ParseLocal(a)
    	fmt.Println(t, err)
    	t, err = dateparse.ParseAny(a)
    	fmt.Println(t, err)
    	t, err = dateparse.ParseStrict(a)
    	fmt.Println(t, err)
    
    }
    

    Result:

    2018-06-29 19:09:57.77297118 +0300 +03
    2018-06-29 03:09:57.77297118 +0300 +03 <nil>
    2018-06-29 03:09:57.77297118 +0300 +03 <nil>
    2018-06-29 03:09:57.77297118 +0300 +03 <nil>
    

    Why only the hour is mangled?

    go version go1.10.2 darwin/amd64
    
    
    opened by mgtest42 5
  • What happens with multiple dates within a string?

    What happens with multiple dates within a string?

    This isn't an issue, but more of an implementation question. Apologies in advance if this is not the right place for a question.

    I have text pages with multiple dates on each page, sometimes with different dates on the same line.

    I was thinking about passing dateparse each line in a file, but from the examples it looks like it only works with single strings. So what is the behavior of dateparse when multiple dates are included within a string?

    I am assuming I need to figure out some method of tokenization of each line in these text files in order to hand dateparse only a single date candidate to convert?

    Thanks in advance

    opened by MedLexAI 5
  • Request: ParseFormat

    Request: ParseFormat

    It would be nice to have a version that outputs a date format string for Go, so that once a format is known it could be used on subsequent parsing more efficiently.

    opened by Redundancy 5
  • Relative dates/times

    Relative dates/times

    Sometimes dates like "today", "now", "yesterday", "3 days ago" come up in data sets and it would be useful to be able to parse these. Maybe a reference date could be set, similar to locale for local parsing?

    opened by rendaw 3
  • Wrong timestamp for RFC3339 formatting (2020-06-26T22:40:16Z)

    Wrong timestamp for RFC3339 formatting (2020-06-26T22:40:16Z)

    Current Behaviour

    Thanks guys for this package! i was able to parse different time formats easily but i face issue with RFC3339 format. i can see this format in the examples 2009-08-12T22:15:09Z, the thing is the package thinks that 2020-06-26T22:40:16Z != 2020-06-26T22:40:16+00:00 in case local timezone not UTC.

    in short if i run the following code locally where my timezone is CEST, the package see that 2020-06-26T22:40:16Z != 2020-06-26T22:40:16+00:00 while it works with go time standard library

    if i run the code where timezone is UTC, it works perfect.

    package main
    
    import (
        "time"
        "fmt"
    
        "github.com/araddon/dateparse"
    )
    
    
    func main() {
    
        thetime, e := time.Parse(time.RFC3339, "2020-06-26T22:40:16Z") // Z means UTC+0
    
        if e != nil {
            panic("Can't parse time format")
        }
    
        epoch := thetime.Unix()
    
        fmt.Println(epoch) // 1593211216 (06/26/2020 @ 10:40pm (UTC))
    
    
        // Works
        thetime, e = dateparse.ParseLocal("2020-06-26T22:40:16+00:00")
    
        if e != nil {
            panic("Can't parse time format")
        }
    
        epoch = thetime.Unix()
    
        fmt.Println(epoch) // 1593211216 (06/26/2020 @ 10:40pm (UTC))
    
        // Don't Work
        thetime, e = dateparse.ParseLocal("2020-06-26T22:40:16Z") // Z means UTC+0
    
        if e != nil {
            panic("Can't parse time format")
        }
    
        epoch = thetime.Unix()
    
        fmt.Println(epoch) // 1593204016 (06/26/2020 @ 8:40pm (UTC))
    
        t := time.Now()
        zone, offset := t.Zone()
        fmt.Println(zone, offset) // CEST 7200
    }
    

    Here is a playground where timezone is UTC https://play.golang.org/p/aOpc22XMiwR

    Expected Behaviour

    Z should be considered +00:00 based on RFC 3339

    Z           A suffix which, when applied to a time, denotes a UTC
                      offset of 00:00; often spoken "Zulu" from the ICAO
                      phonetic alphabet representation of the letter "Z".
    
    Here are some examples of Internet date/time format.
    
          1985-04-12T23:20:50.52Z
    
       This represents 20 minutes and 50.52 seconds after the 23rd hour of
       April 12th, 1985 in UTC.
    

    Anyway in my case i can replace Z with +00:00 or use go standard library but it would be nice if that got fixed since this format is common.

    opened by Clivern 3
  • Refactor to use scylladb/termtables

    Refactor to use scylladb/termtables

    Hello @araddon,

    While I was packaging your library for Debian, I have noticed that one of your dependency is not anymore available.

    As you may all already know, apcera/termtables has come to a end.

    This commit refactor to use the fork from scylladb. ScyllaDB is an organization, so there's less chance that their own fork goes offline too.

    This PR fix #90 and is a lighter fix than the one proposed in #89 (vendoring termtables) because there's nothing else than repairing the library in this PR.

    I don't know what do you think about this. Just let me know If you have another solution. I require your library to package another one, so this fix is really important for me, and I'm willing to take time to do it in another way if you prefer.

    Cheers

    opened by creekorful 3
  • Add test for time.Now() output

    Add test for time.Now() output

    I encountered a problem when trying to parse strings produced by time.Now().String() (e.g. "2009-11-10 23:00:00 +0000 UTC m=+0.000000001" see https://play.golang.org/p/L6NpVXAtSur).

    I'd be surprised if the PR passes tests.

    opened by kwk 3
  • Cannot parse strings which have timezone and skip seconds.

    Cannot parse strings which have timezone and skip seconds.

    I am not able to parse strings which don't have seconds, but contain timezone immediately after minutes. eg:

    package main
    
    import (
    	"fmt"
    
    	"github.com/araddon/dateparse"
    )
    
    func main() {
    	errStrings := []string{
    		"2018-04-02T22:18+0530",
    		"2018-04-02 22:18+0530",
    	}
    	for i, str := range errStrings {
    		if _, err := dateparse.ParseAny(str); err != nil {
    			fmt.Printf("#%d %s: %v\n", i, str, err)
    		}
    
    	}
    }
    

    Output:

    #0 2018-04-02T22:18+0530: parsing time "2018-04-02T22:18+0530" as "2006-01-02T15:48-0700": cannot parse "+0530" as "8"
    #1 2018-04-02 22:18+0530: parsing time "2018-04-02 22:18+0530" as "2006-01-02 15:48-0700": cannot parse "+0530" as "8"
    

    If I put a space after minutes(eg: "2018-04-02T22:18 +0530"), the strings are parsed correctly.

    opened by 2nishantg 3
  • Some forms of PM indicator combined with time zone don't work

    Some forms of PM indicator combined with time zone don't work

    This is a very helpful package, thank you!

    Parsing 2018-09-30 09:09:09PM EST will produce a correct result (the same as 2018-10-01T01:09:09Z), but 2018-09-30 09:09:09 PM EST will be incorrect (it recognizes the PM but not the time zone -- it produces the time value of 2018-09-30T21:09:09Z).

    opened by klondikedragon 1
  • [BUG] some coma-separated words are considered as a time

    [BUG] some coma-separated words are considered as a time

    , although they obviously don't.

    I have prepared a test case replicating the problem and mocked the string we found it with. But I hope the committed one replicates the same issue.

    https://github.com/prochac/dateparse/commit/942edac020cb50c33292ca0743ff69a077b2793d

    opened by prochac 1
  • Support combined datetime format with subseconds (yyyyMMddhhmmss.SSS)

    Support combined datetime format with subseconds (yyyyMMddhhmmss.SSS)

    We have support for a unixy combined timstamp format of the form yyyyMMddhhmmss

    However, some systems log with subseconds appended, for example:

    20140722105203.364
    

    The above should parse as: "2014-07-22 10:52:03.364 +0000 UTC"

    But parsing fails with the error:

    parsing time "20140722105203.364": month out of range
    
    opened by dferstay 0
Owner
Aaron Raddon
CTO/Founder @lytics. Work on golang, distributed data pipelines. Two main side-projects are Golang embedded [x]QL engine qlbridge & @dataux
Aaron Raddon
A fast ISO8601 date parser for Go

A fast ISO8601 date parser for Go go get github.com/relvacode/iso8601 The built-in RFC3333 time layout in Go is too restrictive to support any ISO860

Jason Kingsbury 117 Jan 7, 2023
A natural language date/time parser with pluggable rules

when when is a natural language date/time parser with pluggable rules and merge strategies Examples tonight at 11:10 pm at Friday afternoon the deadli

Oleg Lebedev 1.2k Dec 26, 2022
time format golang

a simple plugin to change date and time format

Ibnu Surkati 2 Sep 29, 2021
Carbon for Golang, an extension for Time

Carbon A simple extension for Time based on PHP's Carbon library. Features: Time is embedded into Carbon (provides access to all of Time's functionali

Uniplaces LTD 742 Dec 20, 2022
Convert string to duration in golang

Go String To Duration (go-str2duration) This package allows to get a time.Duration from a string. The string can be a string retorned for time.Duratio

Santiago De la Cruz 57 Dec 7, 2022
Now is a time toolkit for golang

Now Now is a time toolkit for golang Install go get -u github.com/jinzhu/now Usage Calculating time based on current time import "github.com/jinzhu/n

Jinzhu 4k Dec 23, 2022
Golang package to manipulate time intervals.

timespan timespan is a Go library for interacting with intervals of time, defined as a start time and a duration. Documentation API Installation Insta

null 82 Sep 26, 2022
timeutil - useful extensions (Timedelta, Strftime, ...) to the golang's time package

timeutil - useful extensions to the golang's time package timeutil provides useful extensions (Timedelta, Strftime, ...) to the golang's time package.

Kyoung-chan Lee 190 Dec 22, 2022
A simple, semantic and developer-friendly golang package for datetime

Carbon 中文 | English carbon 是一个轻量级、语义化、对开发者友好的 Golang 时间处理库,支持链式调用和 gorm、xorm、zorm 等主流 orm。 如果您觉得不错,请给个 star 吧 github:github.com/golang-module/carbon g

null 2.8k Jan 9, 2023
Go-olson-timezone - A Golang library that tries to figure out your local timezone

go-olson-timezone A Golang library that tries to figure out your local timezone.

Carlos Henrique Guardão Gandarez 2 Feb 16, 2022
Go-timeparser - Flexible Time Parser for Golang

go-timeparser Flexible Time Parser for Golang Installation Download timeparser w

Kazuaki Yamamoto 2 Dec 29, 2022
A program to create assembly 8086 strings to print without using any printing/strings related function but only mov-xchg-int and loops

Assembly String builder tool A program to create assembly 8086 strings to print without using any printing/strings related function but only mov-xchg-

Reg 2 Feb 1, 2022
How fast could I write tic tac toe in Go, while not knowing Go, but with the aid of GitHub Copilot?

tictactoe-go-with-copilot How fast could I write tic tac toe in Go, while not knowing Go, but with the aid of GitHub Copilot? This took me about 30 mi

null 0 Dec 9, 2021
This package can parse date match expression, which used by ElasticSearch

datemath-parser this package is pure go package, this package can parse date match expression, which used by ElasticSearch. Date Math Definition you c

zhuliquan 0 Jan 8, 2022
This package can parse date match expression, which used by ElasticSearch

datemath-parser this package is pure go package, this package can parse date match expression, which used by ElasticSearch. Date Math Definition you c

zhuliquan 0 Jan 8, 2022
Toy Shader in TinyGo for Game Boy Advance.

toyshader.gba Toy Shader in TinyGo for Game Boy Advance. Releases v0.2: 80x80 screen with 3x2 pixel block version for drawing speed. v0.1: 240x160 pix

Nobuhiro Hatano 14 Oct 29, 2022
The dynamic infrastructure framework for everybody! Distribute the workload of many different scanning tools with ease, including nmap, ffuf, masscan, nuclei, meg and many more!

Axiom is a dynamic infrastructure framework to efficiently work with multi-cloud environments, build and deploy repeatable infrastructure focussed on

pry0cc 3.1k Dec 30, 2022
Count once - Just once? no, when appear many it run once, but it can run many times

countOnce just once? no, when appear many it run once, but it can run many times

null 1 Jan 29, 2022
indodate is a plugin for golang programming language for date convertion on indonesian format

indodate is a package for golang programming language for date conversion on indonesian format

Eko Kurniadi 1 Oct 23, 2021
parse-curl.js golang version. Parse curl commands, returning an object representing the request.

parse-curl.js golang version. Parse curl commands, returning an object representing the request.

StarBus 4 Nov 1, 2022