Skip to content

Commit

Permalink
LibWeb: Use date constants
Browse files Browse the repository at this point in the history
Make the code DRY (Don't Repeat Yourself) by using the `AK`-provided
month name constants instead of copying them.
  • Loading branch information
ldm5180 authored and awesomekling committed Mar 26, 2022
1 parent 83a2aa1 commit 148f816
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Userland/Libraries/LibWeb/Cookie/ParsedCookie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include "ParsedCookie.h"
#include <AK/DateConstants.h>
#include <AK/Function.h>
#include <AK/StdLibExtras.h>
#include <AK/Vector.h>
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 148f816

Please sign in to comment.