Skip to content

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

@jonathan-saunders-ge

Description

@jonathan-saunders-ge

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

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions