-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Invalid date returned from contentResource.getById
#13477
Comments
@nul800sebastiaan @Zeegaan any idea why the date if different than the one returned from the endpoint? |
I think the issue may be inside Umbraco-CMS/src/Umbraco.Web.UI.Client/src/common/services/umbdataformatter.service.js Line 400 in b69afe8
which is called here:
|
Hi @bjarnef 👋 |
Hi @elit0451 It just used the standard datatype instance "Date Picker". Afterwards I changed the property editor to "Label (datetime)" as these data will be imported via a Hangfire job, so using the date picker was mainly to set a data and get a value in the property, but I think it shouldn't matter as the value returned from the endpoint looks correct. Furthermore no content types or properties vary by culture, but we have these languages. We could delete |
I tried changing the property editor back to Date Picker. it seems to make a difference ad the correct date is fetched from The other one mentioned before showing "Invalid date". Maybe there's a difference how date format is stored from date(time) picker and in label (datetime) and how the value is returned from API / Angular. |
For another node I needed to save the node again after change datatype from label (datetime) >date picker as I got "Invalid date". Afterward the date looks correct. I suspect the issue happens when changing datatype from date picker > label (datetime) and save the node again. I guess it may be storing the date in a different format. |
Thanks for investigating! 🙌 Can I get you to update the issue description with those last relevant details and perhaps come up with a simple test scenario that we can work with when reproducing/trying to fix the issue? 🙂 |
Just what I was after 🤩 Thanks a lot Bjarne 🙌 , I will have a look and get back to you |
To reproduce this could be a simple dashboard with a controller and fetch any node:
Then first start with the a property using Date Time (default configuration) and set a date, e.g. December 1st 2022 and check console from code before and compare property data from Next change property editor from Date Time to Label (datetime) and re-save the node. Go back to dashboard and inspect the property data from For other dates e.g. 20th in a month it would probably return an "Invalid date" in the console log as it seems to parse the date incorrect, but it seems the date stored in database and returned from server side is correct. It also explains why this didn't show a difference.
|
Hi again @bjarnef As a last resort, could you try the simplified scenario with the dashboard that you described in the above comment (#13477 (comment)) and let me know if you still get an "Invalid date", as I suspect it could be happening because of what you are doing with the custom |
Hi @elit0451 Regarding my backoffice user it is isn't default "English (United States) - en-US" language. I tried to comment the
With the also when I tested this I got the correct date. So I guess server side everything is as exspected.
But I think Anguar something modify the data returned from |
Hi @elit0451 I have made a nice dashboard for you using default starter kit 😁 On Home Page node I have added this properties using Date Picker with default configuration. Next on Home Page node set December 1st 2022 as start date (v11 release date! 🎉🥳) In dashboard it should show this clicking the "Show details" button. chrome_UjG8Li8JwT.mp4Start Date and End Date properties are included, but only End Date is formatted. If I then change End Date property to using "Label (datetime)" instead. then I get this - notice start and end dates hasn't changed, but end date is formatted as chrome_HYOjmx93eZ.mp4The locale is even though the date stored in database and returned from |
Actually I think you are right that If I modify this in the details controller then end date property in
|
I tried with formatting of date directly using momentjs https://momentjs.com/guides/#/parsing/known-formats/
where
But from date(time) picker the format is I think the property using "Label (datetime)" property editor may return a different formatted value than when using "Date Picker": So parsing this date is no longer in format This seems to work instead.
|
Maybe "Label (datetime)" should have a format property as well? Or maybe the functions in Something like this:
I wonder it that also we fix other issues, where developers has change Date (Time) Picker to another format than |
Nice investigation work Bjarne and super awesome set-up test 🤩 (#13477 (comment)). It was a great idea to send the zip file over! I didn't have time to go through all the details of it today but I can see that you worked/are working on some PRs related to dates? Shall I let you to it and once we have the PRs merged we can close this issue? 😍 |
Hi @elit0451 This PR has been merged #13469 ... but I think we need to new one to specify date string format. It could be something like this:
|
When backoffice has language "English (United States)" the value of label (datetime) is formatted like this:
if I change backoffice user language to "Danish (Denmark)" I get this formatted value instead.
So I would probably need to parse this different based on backoffice user language. |
Thanks for your efforts Bjarne. 💪 I hope this helps to clarify how much easier it is to locate a bug if there is any when we have a simple clean scenario as opposed to custom functions or third parties. I think we can agree that there isn’t any issue in converting from date picker to label(datetime), nor does the angular resource return something wrong. The label changes based on culture (da-culture will cause the dates to behave as Danish), but that is just how it is. The conclusion that you came to in #13477 (comment) is better suited for a discussion about a feature request (being able to set a date time format on the label), so I will go ahead and close this issue so we don’t mix the concepts (bug/feature). 🙂 |
@elit0451 actually I think it is possible to format the datetime here using the However I am not sure how the default value is formatted based on culture. Often it would just be the raw value, but I think in the case there may be something formatting dates based on culture. If would be great if the Label property actually supported this filter and configuration. The filter could probably be based on the selected value type. https://www.w3schools.com/angular/angular_filters.asp and in this case format could be |
Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)
10.2.1
Bug summary
When I use
contentResource.getById()
I get document incl. tabs and properties.However for some
but the endpoint
GetById
does return a valid date.Specifics
No response
Steps to reproduce
Request different documents usings
contentResource.getById
. Depending on the date, some of these are returned as invalid date from angular resource.In this case date is
11/20/2022 12:00:00 AM
which was picked from a date picker and property editor afterwards changed to label, which is shown on the content node. I should also be mentioned that I afterwards changed datatype of the property from date picker to label (datetime), so the nodes which has been saved afterwards may store the value in a different format.Expected result / actual result
No response
The text was updated successfully, but these errors were encountered: