Replies: 3 comments 1 reply
-
|
Hi, thank you for this. However we would really appreciate having a Pull Request that shows what has been changed so we can evaluate the change and merge it. Also, this is not clear about the issue faced on Register History. |
Beta Was this translation helpful? Give feedback.
-
|
I dont know how it was fixed by ai in windsurf . |
Beta Was this translation helpful? Give feedback.
-
Date Parse FixProblem DescriptionThe system was encountering Carbon date parsing errors when trying to parse dates in non-standard formats. The specific error was: This error occurred in the Root CauseThe original Solution ImplementedBefore (Original Code)public function getFormatted( string $date, string $mode = 'full' ): string
{
switch ( $mode ) {
case 'short':
return $this->parse( $date )->format( $this->options->get( 'ns_date_format', 'Y-m-d' ) );
break;
case 'full':
return $this->parse( $date )->format( $this->options->get( 'ns_datetime_format', 'Y-m-d H:i:s' ) );
break;
}
}After (Fixed Code)public function getFormatted( string $date, string $mode = 'full' ): string
{
switch ( $mode ) {
case 'short':
$dateFormat = $this->options->get( 'ns_date_format', 'Y-m-d' );
// Try to parse with the configured format first, then fall back to default parsing
try {
$parsedDate = $this->createFromFormat( $dateFormat, $date );
if ( ! $parsedDate ) {
$parsedDate = $this->parse( $date );
}
} catch ( \Exception $e ) {
$parsedDate = $this->parse( $date );
}
return $parsedDate->format( $dateFormat );
break;
case 'full':
$dateTimeFormat = $this->options->get( 'ns_datetime_format', 'Y-m-d H:i:s' );
// Try to parse with the configured datetime format first
try {
$parsedDate = $this->createFromFormat( $dateTimeFormat, $date );
if ( ! $parsedDate ) {
// Fall back to default parsing
$parsedDate = $this->parse( $date );
}
} catch ( \Exception $e ) {
// Fall back to default parsing
$parsedDate = $this->parse( $date );
}
return $parsedDate->format( $dateTimeFormat );
break;
}
}Key Improvements
Files Modified
Error LocationThe error was occurring at:
TestingAfter the fix, the system should be able to handle:
ImpactThis fix resolves date parsing errors in:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
as says the title i fixed it with this
dateservice.php
Beta Was this translation helpful? Give feedback.
All reactions