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

Improve Date and DateTime parsing #1576

Merged
merged 22 commits into from
Jul 22, 2018
Merged

Improve Date and DateTime parsing #1576

merged 22 commits into from
Jul 22, 2018

Conversation

asbiin
Copy link
Member

@asbiin asbiin commented Jul 15, 2018

Improve how dates and datetimes are parsed and rendered.

Add some function in DateHelper:

  • parseDateTime: parse a string or DateTime object in datetime format
  • parseDate: parse a string or Carbon object in date format
  • getTimestamp: get a timestamp (api format) for a string, Carbon, or SpecialDate
  • getTimezone: get the user timezone

@@ -130,7 +130,7 @@ private function validateUpdate(Request $request)
->respondWithError($validator->errors()->all());
}

$date = Carbon::createFromFormat('Y-m-d', $request->get('next_expected_date'), auth()->user()->timezone);
$date = DateHelper::parseDate($request->get('next_expected_date'));
Copy link
Member Author

Choose a reason for hiding this comment

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

Here next_expected_date must be parsed in iso format.


return [
'signed' => true,
'signed_date' => $signedDate->format(config('api.timestamp_format')),
'signed_date' => DateHelper::getTimestamp($signedDate),
Copy link
Member Author

Choose a reason for hiding this comment

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

signed_date must be render in timestamp format, with UTC timezone

@asbiin asbiin merged commit ed80f54 into master Jul 22, 2018
@asbiin asbiin deleted the fix/carbon-parse branch July 23, 2018 06:00
@djaiss
Copy link
Member

djaiss commented Jul 23, 2018

@asbiin this broke the Settings index view.

Class 'DateHelper' not found (View: /Users/regis/htdocs/monica/resources/views/settings/index.blade.php)

I'll fix it in my PR.

@djaiss djaiss mentioned this pull request Jul 23, 2018
@github-actions
Copy link

github-actions bot commented Feb 5, 2021

This pull request has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants