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

Possible issue with Date formatting #7

Open
mj0126 opened this issue Aug 3, 2017 · 1 comment
Open

Possible issue with Date formatting #7

mj0126 opened this issue Aug 3, 2017 · 1 comment

Comments

@mj0126
Copy link

mj0126 commented Aug 3, 2017

Hi there,

First off, many thanks for putting this together, it has been massively helpful. I just wanted to raise a potential issue I'm seeing with my implementation of the logic here. I'm seeing an error in the developer console stating "Unable to read SObject's field value[s]". A quick search of the error returns a few threads, such as this, seeming to indicate that people have had issues when attempting to save with the YYYY-m-d format.

From what I can tell, it seems like the code should handle this and append a leading zero when necessary or, at least, try to force the YYYY-mm-dd format, but that may not actually be the case. Do you have any guidance or thoughts on where to check to resolve this?

Cheers,
Marc

@rapsacnz
Copy link
Owner

rapsacnz commented Aug 3, 2017

Yes, I have to say my implementation of date parsing (in and out of the component) is pretty rudimentary.
Can you tell me if the date is being generated in the picker, picked in it or is already set externally and is being re-saved back to the server?
I'm guessing that I need to modify parseInputDate starting on line 361 - this is invoked by handleManualDateChange function in the helper, line 317 and it calls parseInputDate on line 329.

A simplistic fix would be to add another format after line 375 in that function (it tries 3 common formats, but you could add more). The reason I haven't done that is that I really need to hook into the built in Localization service to parse the date, as I am hoping that it can do it better than me with it's built in moment :)

Anyway, for now, the easiest fix is to add this after line 375:

if (parsedDate == null || !this.isDateValid(parsedDate)) {
  $A.localizationService.getToday(timezone, function(today) {
    parsedDate = $A.localizationService.parseDateTime(today, 'yyyy-M-d');
  });
}

Let me know if that works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants