@zacharylee_1204 The OSM Opening Hours standard is definitely complex. We have found a good validation tool is the tool Java at https://openingh.openstreetmap.de/opening_hours.js/. You can down load the Javascript from this site or GitHUB. The JavaScriptCaller was deprecated in FME 2019 so instead we have hosted the javascript as a service on Amazon. I've attached an example workspace that has a custom transformer that uses this service.
@zacharylee_1204 The OSM Opening Hours standard is definitely complex. We have found a good validation tool is the tool Java at https://openingh.openstreetmap.de/opening_hours.js/. You can down load the Javascript from this site or GitHUB. The JavaScriptCaller was deprecated in FME 2019 so instead we have hosted the javascript as a service on Amazon. I've attached an example workspace that has a custom transformer that uses this service.
Thank you Mark. I would like to take your suggestion to use the Javascript from GitHUB. May I ask which file I should use as there are so many files in there.
Thank you.
Thank you Mark. I would like to take your suggestion to use the Javascript from GitHUB. May I ask which file I should use as there are so many files in there.
Thank you.
Hi @zacharylee_1204,
The opening_hours.js library is designed to be used in a web app. I used the following procedure to set it up on a very small (and inexpensive) Amazon Web Services EC2 Linux instance:
To set up validation:
To start validation service:
- ssh to instance
- 'node validate.js' to start validation service
- Ctrl-Z to suspend, then 'bg %1' to move the validation to background.
- 'exit' ssh, then close terminal
To use service, send the following request:
http://<instance name>:3000/validate?hours=24/7
The service will return 'passed' for a valid opening hours string, and the opening_hours.js error details for an invalid string
Validate.js:
var express = require('express');
var app = express();
var opening_hours = require('opening_hours');
app.get('/validate', function (req, res) {
try
{
oh_string = req.query.hours;
var test = new opening_hours(oh_string);
res.send("passed");
}
catch(err)
{
res.send(err);
}
})
app.listen(3000);
Thank you Mark. I would like to take your suggestion to use the Javascript from GitHUB. May I ask which file I should use as there are so many files in there.
Thank you.
Thank you very much! Will try it! :)