https://github.com/bnjjj/gomoment
A golang package to parse text that contain date or moment in french into a golang time struct
https://github.com/bnjjj/gomoment
date-parser french golang parser
Last synced: 18 days ago
JSON representation
A golang package to parse text that contain date or moment in french into a golang time struct
- Host: GitHub
- URL: https://github.com/bnjjj/gomoment
- Owner: bnjjj
- License: mit
- Created: 2017-03-16T18:58:48.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-16T20:45:27.000Z (almost 9 years ago)
- Last Synced: 2025-08-15T11:56:02.687Z (6 months ago)
- Topics: date-parser, french, golang, parser
- Language: Go
- Size: 6.84 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://godoc.org/github.com/bnjjj/gomoment)
[](https://travis-ci.org/bnjjj/gomoment)
# gomoment
_gomoment_ is a golang package to parse text that contain date or moment in french into a golang time struct
## Getting started
To use gomoment there is only 1 public function called GetDate, here is some examples:
```golang
func GetDate(moment string, duration bool, location *time.Location) (time.Time, time.Time, error)
```
+ Example for a simple moment date
```golang
begin, _, err := GetDate("Donne moi la date d'aujourd'hui", false, nil)
// begin is the date of today 0h0min
```
+ Other examples for duration
```golang
begin, end, err := GetDate("Combien de km j'ai réalisé depuis le mois dernier ?", true, nil)
// begin is today - 1 month and end is today 00:00
```
+ Example with another location
```golang
location, _ := time.LoadLocation("America/New_York")
begin, end, err := GetDate("Combien de km j'ai réalisé hier ?", true, location)
```
## Examples of text date that *gomoment* can parse
+ `avant-hier ?`
+ `la veille`
+ `hier`
+ `5 jours`
+ `7j`
+ `2 semaines`
+ `2sem`
+ `5mois`
+ `ce mois-ci`
+ `la semaine passée `
+ `cette semaine`
+ `cette annéee`
+ `5 décembre 2015`
+ `le 5 janvier`
+ `le 5/01/2017`
## References
It's the package used for [Talk to my car](http://www.talk-to-my-car.com)
## Contributions
Feel free to contribute and extend this package and if you have bugs or if you want more specs make an issue. Have fun !
-------------
Made by [Coenen Benjamin](https://twitter.com/BnJ25) with love