hapi-server / uri-templates

Repository of tools for URI templates
Apache License 2.0
2 stars 0 forks source link

Issue with $j in end time? (JavaScript implementation) #23

Closed ericthewizard closed 7 months ago

ericthewizard commented 8 months ago

I was just testing the JS implementation and ran into a potential problem:

const filename = "ac27_crn1926_199722300-199725000.gif";
const template = "ac27_crn$x_$Y$j00-$(Y;end)$(j;end)00.gif"

ut = new URITemplate(template);

console.log(ut.parse(filename));

Prints:

[1997, 8, 11, 0, 0, 0, 0, 1997, 1, 250, 0, 0, 0, 0]

So it gets the month/day of month correct for the start time, but is still using the DOY with month = 1 for the end time.

jbfaden commented 8 months ago

Thanks for pointing this out. This same error is likely in the Java and Python implementations, since I use a code conversion to make the JavaScript version. I can look at this right now.

jbfaden commented 8 months ago

The test URITemplateTest.testParse tests this now, and the Java version is fixed. Now converting to Python and JavaScript.

ericthewizard commented 8 months ago

Thanks!

jbfaden commented 8 months ago

It's passing the JavaScript tests, so I think it's good now. (Incidentally do you know how to do unit testing in JavaScript? I kludged something up, and I can see it's testing the new code.)

ericthewizard commented 8 months ago

I've been using Jest:

https://jestjs.io

Very easy to get started and add new test cases!

Thanks again!

jbfaden commented 8 months ago

I'll have a look. (Especially if I can ask you questions!)

ericthewizard commented 8 months ago

I'll have a look. (Especially if I can ask you questions!)

Absolutely! In case you're not aware, my new email is eric.grimes at nasa.gov (note: my UCLA email isn't checked anymore, so please don't send any questions there!)

ericthewizard commented 7 months ago

When you get a chance, can you update the Python version as well (with this fix)? I'm still running into this issue there:


>>> test_file = "https://spdf.gsfc.nasa.gov/pub/pre_generated_plots/kp_plots/ace/gif/ac_199733000-199733100.gif"
>>> digits = ut.parse(test_file, {})
>>> digits
[1997, 11, 26, 0, 0, 0, 0, 1997, 1, 331, 0, 0, 0, 0]
jbfaden commented 7 months ago

Weird that I didn't get it back in December. I'll fix it now. Thanks for pointing this out.

jbfaden commented 7 months ago

Eric, I think this is fixed now. Let me know if you don't see a change. I forget if this is released on PyPi, I don't think it is.

ericthewizard commented 7 months ago

Thanks! Definitely working for me now. I'm not sure if it's in PyPI - I'm downloading the zip from GifHub