-
-
Notifications
You must be signed in to change notification settings - Fork 831
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
Support for multiple date formats #29
Comments
Hi, @vikasganiga05! That would be great! The function that would need to be updated is In the function, it should check a URL parameter, for example The date can be converted to a string using PHP's format function as is already done. If no date format is specified, the default formatting should be used. It might make sense to tell the user to use format characters from PHP in the URL parameter. This would make the function simpler and allow full customization. It would be nice to also have an option to hide the year when the year is the current year like the default currently does (basically remove the year -- which can be If you have any further questions, feel free to ask! |
How the user provides the date format as a URL parameter, I mean the format of URL paremeter. |
I'm open to new ideas, but my current thought is something like this: Parameter:
|
One more idea could be to combine them into one parameter by having brackets to represent the part to skip during the current year (See examples below). The default value would be Let me know what you think. Examples:
|
This idea sounds good, I will work on this. |
@vikasganiga05 That's a good start. In the end, we will need two strings, one to go into the call to The date_format will need to be retrieved from a parameter passed to the function, for example, Every time the Your code looks good, I would probably do it without the $differentYear = str_replace(array("[", "]"), "", $format);
$sameYear = preg_replace("/\[.*?\]/", "", $format); If you have more questions, don't hesitate to ask! 🤗 |
Ok, So I want to create a new dropdown for Date Formates. The default value will be |
When I run the function formatDate(string $dateString, string $format): string
{
$date = new DateTime($dateString);
$isSameYear = preg_replace("/\[.*?\]/", "", $format);
$sameYear = preg_replace("/\[.*?\]/", "", $format);
$differentYear = str_replace(array("[", "]"), "", $format);
// if current year, display only month and day
if (date_format($date, "Y") == date("Y") && $isSameYear) {
return date_format($date, $sameYear);
}
// otherwise, display month, day, and year
return date_format($date, $differentYear);
} |
Since Also, it would be great if you could add assertions to the tests that verify that the new feature will work in all cases. Feel free to open a PR and I can leave comments there. |
Sorry, my bad I forgot to change. It will be |
It seems to me that checking |
Ok, I will remove it. The If condition look good? |
I think |
Hi @vikasganiga05, any new progress on this? |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days |
Hi @vikasganiga05, it looks like it should be close to being ready, do you plan to finish this? |
Since this has been open since February, I will unassign this issue in 7 days if there is no response. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days |
Currently, all dates are displayed with month, day, and when applicable, year. For example, "Feb 16" or "Dec 31, 2020".
It may be possible to allow the user to optionally choose their preferred date format through a URL parameter. For example, if the user prefers the day before the month, they can display dates that way.
The text was updated successfully, but these errors were encountered: