{"ScriptPreparationCode":"var date = new Date(2021, 2, 24)\r\n\r\nvar formatDateByIntlDateTimeFormat = (date) =\u003E {\r\n return new Intl.DateTimeFormat(\u0027pt-BR\u0027).format(date)\r\n}\r\n\r\nvar tokens = {\r\n // Padded day = 01, 02, ..., 31\r\n DD: (date) =\u003E date.getDate().toString().padStart(2, \u00270\u0027),\r\n // Padded month = 01, 02, ..., 12\r\n MM: (date) =\u003E (date.getMonth() \u002B 1).toString().padStart(2, \u00270\u0027),\r\n // Padded year = 0001, 0002, ..., 1995, ..., 2020, 2021\r\n YYYY: (date) =\u003E date.getFullYear().toString().padStart(4, \u00270\u0027),\r\n};\r\n\r\nvar formatDateByReduceReplace = (date, format = \u0027DD/MM/YYYY\u0027) =\u003E {\r\n return Object.entries(tokens).reduce(\r\n (result, [pattern, fn]) =\u003E result.replace(new RegExp(pattern, \u0027g\u0027), fn(date)),\r\n format\r\n );\r\n};","TestCases":[{"Name":"Intl.DateTimeFormat","Code":"formatDateByIntlDateTimeFormat(date)","IsDeferred":false},{"Name":"Reduce/Replace Format","Code":"formatDateByReduceReplace(date, \u0027DD/MM/YYYY\u0027)","IsDeferred":false}]}