Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getOverview() uses incorrect date format #117

Closed
jacob-kinzer opened this issue Feb 12, 2019 · 1 comment
Closed

getOverview() uses incorrect date format #117

jacob-kinzer opened this issue Feb 12, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@jacob-kinzer
Copy link

jacob-kinzer commented Feb 12, 2019

Webapp

Summary

It looks like the getOverview() method in the typescript formats the fromDay variable using getters on javascript date object.

Example line

fromDay = today.getFullYear() + '-' + today.getMonth() + '-' + today.getDate();

Specifically getMonth will return a single digit value for most months and the backend api is expecting an format of YYYY-MM-DD and produces an error.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth

@RequestParam(name = "from", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date fromDate,

Reproduce steps

Log into pacbot and load the home page with the compliance overview chart.

Expected Results

The proper date passed to the API for the charts and allowed to be parsed correctly.

Actual Results

https://user-images.githubusercontent.com/40577885/52662044-ffb68780-2ec8-11e9-9066-a702ffad79bb.png

https://user-images.githubusercontent.com/40577885/52662630-51134680-2eca-11e9-8e22-439f027de474.png

Possible Fix

This could potentially be fixed by just using ISO string and sub string adequately fromDay = today.toISOString().substring(0, 10);

https://user-images.githubusercontent.com/40577885/52662744-946db500-2eca-11e9-9421-a215693294d2.png

Aha! Link: https://t-mobile1t-mobile.aha.io/features/PM-302

@jacob-kinzer
Copy link
Author

I thought about my 'possible fix' for this and actually it doesn't really fit the need. While it would always give you a 2 digit date code, it would set the graphs up to never look past today's date. You would probably want to do something more like

          today.setMonth(today.getMonth() - 1);
          fromDay = today.toISOString().substring(0, 10); 

Or if you wanted to keep using the getMonth() method maybe something like
("0" + (today.getMonth() + 1)).slice(-2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants