Closed Chriz74 closed 2 years ago
@Chriz74 in what scenario you need to counter date as an object? And why didn't you convert that date to number? For example, you can use .getFullYear()
to get the year as number.
Or you can give me your piece of code from jsfiddle or pastebin, so I can test it.
Here is a simple basic setup: https://jsfiddle.net/cmuschiol/uj07dska/7/
What i want to achieve is the number "2005" and not "2.005" ... so no '.' in it.
@Chriz74 Let me see... This code works well on my browser. But I think this can be happen because we use .toLocaleString(undefined, ...)
to format number to string. And we just detect comma(s) as separator in here new RegExp(/,/gi, 'gi')
.
Maybe this issue will appear on some locales
that doesn't use comma(s) to separate thousands number.
i am testing with german browser (de_DE) ...
@Chriz74 can you share a screenshot of the result you're getting please
edited my reply with screenshot :)
@Chriz74 well, accoding to MDN, de_DE
use dot(s) (or whatever it name) as thausands separator.
@Chriz74 well, accoding to MDN,
de_DE
use dot(s) (or whatever it name) as thausands separator.
Right but there might be situations where formatting would want to be turned off. Forexample if you want to represent counting through a series of years. Then thousand seperators doesn't make much sense.
Imo. we need a setting to remove formatting: formatter=false ideally we'd also accept closures just so users can really customize how they want it presented.
Possible values: boolean [off], closure, string='locale' (default - because that's what we currently do)
@Chriz74 I'm just create PR #32 for this issue. You can check out my repository and test it to your project...
For the JS file, you can use this link https://rzlnhd.github.io/purecounterjs/dist/purecounter_vanilla.js
or https://rzlnhd.github.io/purecounterjs/dist/purecounter.js
.
You can specify formater
configuration on HTML element, or when you declare new PureCounter()
. The formater accept string
for locale (by default is "en-US"
), or you can turn it off by set the value to false
. More detail just check my PR Submission
Works like a charm :) Thank you!!!!
I'll be merging this in tonight (in about 12 hours from now)
This feature is live in version 1.5.0+ thanks for the suggestion @Chriz74
Is it possible to remove the '.' on thousands? I try to count to a year e.g. 2020. It displays then 2.021
'separator = false' seems to work only for decimals ...