Creates an instance of date localizer.
the string of the date to localize. The format expected is YYYY | YYYY/MM | YYYY/MM/DD.
The date splitted in an Array
the string of the date to localize. The format expected is YYYY | YYYY/MM | YYYY/MM/DD.
The formats to use to format the localized date.
The localized and formatted date.
Adds day to properly work with the string as a date where the user did not provide one. Since we don't care about the day anyways, the first of them onth is added.
Analyzes date to determine how many info have been passed (YYYY | YYYY/MM | YYYY/MM/DD). If only the year was passed, the localization can end here as the is no actual formatting to do.
Starts the localization logic.
Processe situazions in which we also have the month or month and day. It calls setFormat
to determine if the final date should have the day or not. After, if the day was not passed, it calls addDay
to add the day value as we cannot work on a partial date. This will not be shown as we have already set a formatting that does not show the day if the user passed a date without the day.
Sets the formatting for the localDate
to return. If no day was passed, a format without day is set. Else, a full date format is set.
Sets the full date by year, month and day on moment
and formats it.
Sets the locale on moment
.
Sets the year on the final localDate
to return.
Splits the date by the forward slash. The first element of the Array will be the Year, the second the Month, the third the day.
Localazes date to a given locale.