12345678910111213141516171819202122232425262728293031323334353637 |
- /*
- * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
- #include <LibJS/Runtime/Temporal/Calendar.h>
- #include <LibJS/Runtime/Temporal/PlainDate.h>
- #include <LibJS/Runtime/Value.h>
- namespace JS::Temporal {
- // 3.5.5 IsValidISODate ( year, month, day ), https://tc39.es/proposal-temporal/#sec-temporal-isvalidisodate
- bool is_valid_iso_date(i32 year, i32 month, i32 day)
- {
- // 1. Assert: year, month, and day are integers.
- // 2. If month < 1 or month > 12, then
- if (month < 1 || month > 12) {
- // a. Return false.
- return false;
- }
- // 3. Let daysInMonth be ! ISODaysInMonth(year, month).
- auto days_in_month = iso_days_in_month(year, month);
- // 4. If day < 1 or day > daysInMonth, then
- if (day < 1 || day > days_in_month) {
- // a. Return false.
- return false;
- }
- // 5. Return true.
- return true;
- }
- }
|