globalizejs / globalizejs/globalize

Expose the localized date format used by dateParser

Open
#778 7 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.8k
Forks
585
PR merge metrics
No merged PRs in 30d

Description

I need to show the LOCALIZED format string as a guidance to users entering values into textboxes.
In my case I need this for dates, and I was able to find a "hack" as follows:

```typescript
const parser = Globalize.dateParser(options);
const format: string = parser.runtimeArgs[2].pattern;

// 'format' variable will be different for different locales when options are same
// locale "en-US" with options { skeleton: 'yyyyMMdd' } => 'MM/dd/yyyy'
// locale "en-UK" with same options => 'dd/MM/yyyy'
```

But when running the application after uglifying my scripts in the webpack optimized build, the runtimeArgs propery of the parser is undefined. I guess this runtimeArgs property was not meant to be exposed to the outside world anyway.

Is there some other way that I can get this, or could you potentially consider this a feature request?

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.