Giter Site home page Giter Site logo

when's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

when's Issues

Dependent dates

when cannot parse dates with relative delta from some date:

gore> r, err := w.Parse("завтра в 12:00 поезд, напомни за час", time.Now())
&when.Result{
  Index:  0,
  Text:   "завтра в 12:00",
  Source: "завтра в 12:00 поезд, напомни за час",
  Time:   2019-02-28 12:00:28 Local,
}
nil

BTW, I have old rutimeparser lib for Python. Maybe, some test cases will be useful for you.

Ability to use a different timezone?

I couldn't see to find any timezone parsing code. So, for example, if I am saying "10 PM EST" while the machine's local time is in PST then I expect 7 PM as the outcome in local time or 10 PM with the timezone information extracted.

Is it possible to have 'deadlines' extended to work without 'in/within'

It would be nice to be able to parse "2 hours" or "4 days" instead of requiring the in/within, maybe it's a bit "noisy" but if it were possible via an option or some sort of "aggressive" version of deadline i think it could be nice - sometimes you just want to parse a time no matter what, and it won't always have the in/within at the start

"September" always incorrectly parsed as October

Not sure why this is happening, but the following strings are yielding results that are a month off:

when.Parse("September 5th", time.Now()) => 2018-10-05 23:41:28.856911 -0700 PDT
when.Parse("Sept. 5th", time.Now()) => 2018-10-05 23:41:52.679274 -0700 PDT
when.Parse("Sep 5", time.Now()) => 2018-10-05 23:41:52.679274 -0700 PDT

Correct:

when.Parse("October 5th", time.Now()) => 2018-10-05 23:42:06.57631 -0700 PDT

Multiple matches

For example, a sentence

breakfast at 8.00, lunch at 12.00

contains 2 matches. Is it possible to extract both of them and return all results?

bias ExactMonthDate towards future dates

Hi! I picked up when in a quick project to file tasks into notion, and it's been great so far! I'm glad I don't have to rewrite all of this natural time parsing myself. Being the end of the year, I've been trying to schedule tasks for next January when I go back to work, and was surprised when they were parsed as January of 2021 instead of 2022.

I was wondering:

  • Is it intentional that ExactMonthDate parses, e.g. January 4th as 2021-01-04 instead of 2022-01-04?
  • If not, would it be possible to bias ExactMonthDate the next occurrence of the date? This is a breaking change to the library, so I understand if it's not acceptable to upstream.

I do have a working approach (that isn't particularly well thought out 😁) which I could turn over to a pull request if y'all are interested.

Thanks!

Common expression for "next week on <day>" in Dutch

Hi there,

As the codeowner of the Dutch language in when, I propose the addition of support for a common expression in Dutch. It's now friday, let's say that I want to make an appointment for next wednesday. In Dutch it's just as common to say "volgende week woensdag" (which translates to "next week on wednesday") as to say "komende woensdag" (which translates to "next wednesday"). So I'd like to add support for "volgende week woensdag" as well.

Before implementing this feature, I thought it might be best to discuss it here, maybe other supported languages have the same pattern. In that case it could be beneficial to work together on this.

My kind regards,
Reinder.

semver release ?

Can we have a semver release of this package - x.y.z , say 1.0.0 so it becomes easy to integrate the same in apps and track future changes if any ?

Common US dates not working.

Not getting a date back for standard U.S. format: "10/20" or "10/20/17". Getting a panic on "10/20/2017":

package main

import (
	"fmt"
	"os"
	"time"

	"github.com/olebedev/when"
	"github.com/olebedev/when/rules/common"
	"github.com/olebedev/when/rules/en"
)

func main() {
	w := when.New(nil)
	w.Add(en.All...)
	w.Add(common.All...)

	text := "10/20/2017"
	r, err := w.Parse(text, time.Now())
	if err != nil {
		fmt.Printf("Error: %s\n", err)
		os.Exit(1)
	}
	if r == nil {
		fmt.Println("NO MATCH")
		os.Exit(1)
	}

	fmt.Println(
		"the time",
		r.Time.String(),
		"mentioned in",
		text[r.Index:r.Index+len(r.Text)],
	)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.