1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

LibWeb: Use date constants

Make the code DRY (Don't Repeat Yourself) by using the `AK`-provided
month name constants instead of copying them.
This commit is contained in:
Lenny Maiorani 2022-03-26 16:55:39 -06:00 committed by Andreas Kling
parent 83a2aa1832
commit 148f8169a4

View file

@ -5,6 +5,7 @@
*/
#include "ParsedCookie.h"
#include <AK/DateConstants.h>
#include <AK/Function.h>
#include <AK/StdLibExtras.h>
#include <AK/Vector.h>
@ -263,10 +264,8 @@ Optional<Core::DateTime> parse_date_time(StringView date_string)
};
auto parse_month = [&](StringView token) {
static const char* months[] { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" };
for (unsigned i = 0; i < 12; ++i) {
if (token.equals_ignoring_case(months[i])) {
if (token.equals_ignoring_case(short_month_names[i])) {
month = i + 1;
return true;
}