Generating `daysOfTheWeek` array with only first character
See original GitHub issuehttps://github.com/kylestetz/CLNDR/blob/555cf44c19dbf719c559a3ae86314d3eae0c5a25/src/clndr.js#L348
When this plugin generates daysOfTheWeek
array from momentjs localized dd
format, it only considers the first character, even when it formats it with the “min” version from momentjs.
In Catalan, for example, every day name begins with same letter d
(dilluns, dimarts, dimecres, …), so I end up having a day names header full of D
.
Would you consider respecting whatever comes from momentjs when formatting it with dd
?
Or at least, give an option to let us chose without the need to fill this array everytime we instantiate a new CLNDR?
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
javascript array only first character displayed - Stack Overflow
So, to summarize... split() Splits a String object into an array of strings by separating the string into substrings.
Read more >Use the map method on the daysOfWeek array, creating a ...
The "charAt" method will return just one single character. You could potentially call it 3 times and combine with concatenation. For creating a ......
Read more >Documentation: 15: 8.15. Arrays - PostgreSQL
To illustrate the use of array types, we create this table: ... this query retrieves the first item on Bill's schedule for the...
Read more >How to get the first three characters of a string using JavaScript
Create an array containing the days of the week. By using the index get the preferred day name. By using the slice method...
Read more >How to create an array of type string and initialise it to the days ...
Let's just assume you were to code this problem in java. There are several ways you can initialize the array to the days...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@aprat84 thanks for pointing this out, we definitely want to support more flexible day headers.
@mikegioia I like your idea! What if we take it a tad further and expose a function
formatWeekdayHeader
that exposes a moment object set to the correct weekday and allows you to return any string? That would allow you to run both.format('dd')
or do some more complicated logic for a given locale (like we currently do withcharAt
). The default could be(m) => m.format('dd').charAt(0)
or we could improve things by doing theen
locale check that you suggested. I like this because it also opens up the possibility of e.g. doing completely custom headers by inspectingm.weekday()
and pulling from your own array of strings.Thoughts? Would this work for you @aprat84?
@aprat84 @kylestetz This is now added to version 1.5.1, and updated in NPM!