Skip to content
forked from chneau/openhours

A "opening_hours" from openstreetmap like

License

Notifications You must be signed in to change notification settings

Vivino/openhours

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openhours

A compromise of complexity of the "opening_hours".
Only the `day-day time-time" will work for now.

Online tools

https://openingh.openstreetmap.de/evaluation_tool/?setLng=en

Example

oh := openhours.New("Mo-Fr 09:00-17:00")
t := time.Date(2019, 3, 6, 10, 0, 0, 0, time.Now().Location())
// oh.Location = t.Location() //default to system but can be changed this way

fmt.Println("t =", t)

isOpen := oh.Match(t)
fmt.Println("Is it open at this date?", isOpen)

_, duration := oh.NextDur(t)
fmt.Println("For how long?", duration)

_, date := oh.NextDate(t)
fmt.Println("When will it close?", date)

fmt.Println(" +++++++++++++++++++++ ")

t = time.Date(2019, 3, 6, 18, 0, 0, 0, time.Now().Location())

fmt.Println("t =", t)

isOpen, date = oh.NextDate(t)
fmt.Println("Is it open?", isOpen, "Ok, when will it open then ?", date)

/* output
t = 2019-03-06 10:00:00 +0000 GMT
Is it open at this date? true
For how long? 7h0m0s
When will it close? 2019-03-06 17:00:00 +0000 GMT
 +++++++++++++++++++++
t = 2019-03-06 18:00:00 +0000 GMT
Is it open? false Ok, when will it open then ? 2019-03-07 09:00:00 +0000 GMT
*/

About

A "opening_hours" from openstreetmap like

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%