From 3621e4ba07219d8bccb5e764a92e83382a1a89c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 11 Sep 2019 19:33:46 +0800 Subject: [PATCH] Support formating with '\n' --- src/format/index.js | 2 +- src/format/test.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/format/index.js b/src/format/index.js index dfd5854e7b..dd24f12bac 100644 --- a/src/format/index.js +++ b/src/format/index.js @@ -29,7 +29,7 @@ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$) // sequences of symbols P, p, and the combinations like `PPPPPPPppppp` var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g -var escapedStringRegExp = /^'(.*?)'?$/ +var escapedStringRegExp = /^'([^]*?)'?$/ var doubleQuoteRegExp = /''/g var unescapedLatinCharacterRegExp = /[a-zA-Z]/ diff --git a/src/format/test.js b/src/format/test.js index 55dad9c707..d5655712d1 100644 --- a/src/format/test.js +++ b/src/format/test.js @@ -50,6 +50,11 @@ describe('format', function() { assert(format(date, "''h 'o''clock'''") === "'5 o'clock'") }) + it('accepts new line charactor', function() { + var date = new Date(2014, 3, 4, 5) + assert.equal(format(date, "yyyy-MM-dd'\n'HH:mm:ss"), '2014-04-04\n05:00:00') + }) + describe('ordinal numbers', function() { it('ordinal day of an ordinal month', function() { var result = format(date, "do 'day of the' Mo 'month of' yyyy")