globalizejs / globalizejs/globalize

dateFormatter with raw pattern isn't handling two single quotes correctly when outside quoted text

Open
#822 1 comment 0 reactions 0 assignees View on GitHub
bug date module
Dominant language
JavaScript
Stars
4.8k
Forks
585
PR merge metrics
No merged PRs in 30d

Description

Thanks for this great package! :-)

The LDML spec says: "Two adjacent single vertical quotes (''), which represent a literal single quote, either inside or outside quoted text."

However `globalize.dateFormatter({raw: "h''m''s''"})` returns "456" instead of "4'5'6'".

I ran this over at https://npm.runkit.com/globalize

```javascript
var Globalize = require("globalize")
Globalize.load( require( "cldr-data" ).entireSupplemental() );
Globalize.load( require( "cldr-data" ).entireMainFor( "en" ) );
Globalize.loadTimeZone( require( "iana-tz-data" ) );
var globalize = Globalize( "en" ),
date = new Date( 2001, 2-1, 3, 4, 5, 6, 789 );
var check = function (fmt) {
console.log(fmt + ' ==> ' + globalize.dateFormatter({raw: fmt})(date));
};
check("h''m''s''"); // fails, expect 4'5'6' but get 456
check("'h''m''s'''"); // works, expect h'm's'
check("h''''m''''s"); // fails, expect 4'5'6 (or 4''5''6, unclear from spec?) but get 456
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.