-
Notifications
You must be signed in to change notification settings - Fork 85
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
Added a button to normalize the date. #37
base: gh-pages
Are you sure you want to change the base?
Conversation
This will force the parsed date to be output as "YYYY-MM-DD", a format that YNAB is guaranteed to accept.
src/data_object.js
Outdated
@@ -101,6 +102,22 @@ window.DataObject = class DataObject { | |||
tmp_row[col] = cell; | |||
} | |||
break; | |||
case "Date": | |||
if (normalize_date) { | |||
var d = new Date(cell), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some date format detection and shaping is necessary before this will work, cell
can be in a lot of formats that wont work with new Date()
. I believe this is why date formatting has not been added so far: #10
Hey @shaperilio what's the date format you get from Venmo? Would you mind sharing a few anonymised statement lines? The code was previously always using
Also sorry you had to wait for a response for so long 🙏 |
Hello @aniav; no worries on the wait. This is what I got from Venmo this morning:
It is unrecognizable by YNAB, as we know. After running through your tool, YNAB does not recognize the date (which is taken directly from the CSV, e.g. the first one above is Forgive my crude code for the Javscript universe is a world of confusion to me. To @denkristoffer's point, if you don't select the "Datetime" column and choose to normalize the date, you'll get "NaN-NaN-NaN", which I certainly find sufficient to indicate the user made a mistake (in part because I don't have the capacity to do anything more elegant). Date parsing is always a nightmare, but something must have changed in the way Venmo outputs things (or the way YNAB imports things) and this works today (and has since I made the modification). We will likely have to do something again next time something changes. I don't think we need to worry about nnnn-nn-nn being confused as month-day or day-month, nor do we need to check the format of the date in Venmo's output. Perhaps a better way to do this is to simply throw away the string beyond the "T"; that way we are not interpreting the date in any way, and if Venmo changes the format, it may be more robust against mangling the date. When I import what my version outputs with "normalized date" turned on, YNAB does not let me choose the date format. Examining the screenshot carefully, you can see that if you use hyphen as a separator, the only possibility is YYYY-MM-DD (however, YYYY/DD/MM and YYYY/MM/DD both exist). This lucky coincidence means we don't really need to communicate the format to the user. Curiously, YNAB has a checkbox to "Adjust to local time", despite presumably not accepting any formats with the time included. Checking this box sets all my dates back a day. I think Venmo is outputting UTC. Of note is that the thousands separator is a comma, and that transaction amount appears in quotes. Venmo is only available in the United States; do we have to worry about any internationalization? If we know the Venmo output format is universally the same for all customers, there shouldn't be a "normalize" toggle at all. |
This will force the parsed date to be output as "YYYY-MM-DD", a format that YNAB is guaranteed to accept.
This was tested with real Venmo transactions, which were otherwise unimportable.