Skip to content

Fix for incorrect Date serialization for format: date #17284

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,7 @@ export class ObjectSerializer {
return transformedData;
} else if (type === "Date") {
if (format == "date") {
let month = data.getMonth()+1
month = month < 10 ? "0" + month.toString() : month.toString()
let day = data.getDate();
day = day < 10 ? "0" + day.toString() : day.toString();

return data.getFullYear() + "-" + month + "-" + day;
return data.toISOString().substring(0,10);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this change, IIRC this caused troubles in the past when someone uses a local date and expects the local representation to be transferred over the wire, as opposed to a full iso string where the time zone information is there.

@TiFu any opinion here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@macjohnny, thank you for sharing your concern. While I'm confident that the dates should be transferred between the client and server with the UTC timezone, the main problem that I explained in #17272 is that the serialize and deserialize methods are incompatible. This is because the current deserialize method implementation expects the date with the UTC timezone.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TiFu @macjohnny, hi guys. Do you have any updates on this issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akehir @amakhrov what is your take on this?

} else {
return data.toISOString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,7 @@ export class ObjectSerializer {
return transformedData;
} else if (type === "Date") {
if (format == "date") {
let month = data.getMonth()+1
month = month < 10 ? "0" + month.toString() : month.toString()
let day = data.getDate();
day = day < 10 ? "0" + day.toString() : day.toString();

return data.getFullYear() + "-" + month + "-" + day;
return data.toISOString().substring(0,10);
} else {
return data.toISOString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,7 @@ export class ObjectSerializer {
return transformedData;
} else if (type === "Date") {
if (format == "date") {
let month = data.getMonth()+1
month = month < 10 ? "0" + month.toString() : month.toString()
let day = data.getDate();
day = day < 10 ? "0" + day.toString() : day.toString();

return data.getFullYear() + "-" + month + "-" + day;
return data.toISOString().substring(0,10);
} else {
return data.toISOString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,7 @@ export class ObjectSerializer {
return transformedData;
} else if (type === "Date") {
if (format == "date") {
let month = data.getMonth()+1
month = month < 10 ? "0" + month.toString() : month.toString()
let day = data.getDate();
day = day < 10 ? "0" + day.toString() : day.toString();

return data.getFullYear() + "-" + month + "-" + day;
return data.toISOString().substring(0,10);
} else {
return data.toISOString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,7 @@ export class ObjectSerializer {
return transformedData;
} else if (type === "Date") {
if (format == "date") {
let month = data.getMonth()+1
month = month < 10 ? "0" + month.toString() : month.toString()
let day = data.getDate();
day = day < 10 ? "0" + day.toString() : day.toString();

return data.getFullYear() + "-" + month + "-" + day;
return data.toISOString().substring(0,10);
} else {
return data.toISOString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,7 @@ export class ObjectSerializer {
return transformedData;
} else if (type === "Date") {
if (format == "date") {
let month = data.getMonth()+1
month = month < 10 ? "0" + month.toString() : month.toString()
let day = data.getDate();
day = day < 10 ? "0" + day.toString() : day.toString();

return data.getFullYear() + "-" + month + "-" + day;
return data.toISOString().substring(0,10);
} else {
return data.toISOString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,7 @@ export class ObjectSerializer {
return transformedData;
} else if (type === "Date") {
if (format == "date") {
let month = data.getMonth()+1
month = month < 10 ? "0" + month.toString() : month.toString()
let day = data.getDate();
day = day < 10 ? "0" + day.toString() : day.toString();

return data.getFullYear() + "-" + month + "-" + day;
return data.toISOString().substring(0,10);
} else {
return data.toISOString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,7 @@ export class ObjectSerializer {
return transformedData;
} else if (type === "Date") {
if (format == "date") {
let month = data.getMonth()+1
month = month < 10 ? "0" + month.toString() : month.toString()
let day = data.getDate();
day = day < 10 ? "0" + day.toString() : day.toString();

return data.getFullYear() + "-" + month + "-" + day;
return data.toISOString().substring(0,10);
} else {
return data.toISOString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,7 @@ export class ObjectSerializer {
return transformedData;
} else if (type === "Date") {
if (format == "date") {
let month = data.getMonth()+1
month = month < 10 ? "0" + month.toString() : month.toString()
let day = data.getDate();
day = day < 10 ? "0" + day.toString() : day.toString();

return data.getFullYear() + "-" + month + "-" + day;
return data.toISOString().substring(0,10);
} else {
return data.toISOString();
}
Expand Down