quasar icon indicating copy to clipboard operation
quasar copied to clipboard

[Request] The case of week and weekofyear

Open spectrolite opened this issue 9 years ago • 3 comments

I decided to post this separately from #640, with a few adjustments for the sake of clarity

according to http://beta.quasar-framework.org/components/handling-js-date.html#Format-for-display we can format a date using ww or simply w if you don't need 0-padding to output the week of year. We can also get it like this date.getWeekOfYear(anyDay)

but we have no way to specify a date by year + week

more specifically, week is absent from

addToDate()
subtractFromDate()
adjustDate()

which all accept already :

-milliseconds -seconds -minutes -hours -days -month -year

ok a week is just 7 days so it's not a big issue, but why not add week for added convenience ?

week and weekofyear would be greatly useful in isSameDate , which would essentially mean resp. “these 2 days happen less than a week apart” or “..in the same calendar week”, both pretty useful!, and also as units in

getDateDiff
startOfDate
endOfDate

knowing which day is the first day of the week is indeed important.

spectrolite avatar Jul 28 '17 14:07 spectrolite

this gitter excerpt might be useful in better understanding the issue and its pitfalls for users/developers.

Laurent @spectrolite 16:30 there’s 2 things here at play 1 - week as a unit of time (=7days) 2 - week of the year as calendar anchors (like months) [aka. week of year or calendar year]

John @JCharante 16:32 and you need a third, starting day because the world is divided on starting on saturday/sunday/monday

Laurent @spectrolite 16:34 no need for a third, it’s just a variant on 2.

1 and 2 are two ways to look at the word week we need the code to support both atm it supports 1 through the use of 7days, and 2 as an analysis tool (getWeekOfYear), but not to create or manipulate (add, compare etc) date objects. I say we need more explicit support for week, both as a unit (instead of 7days, to help write clean code) and as calendar weeks (Week of Year), eg. allow to create a date from year + weekofyear.

spectrolite avatar Jul 28 '17 15:07 spectrolite

FYI - in Quasar 1.0 there is an App Extension called QCalendar. This approach has been treated there. https://quasarframework.github.io/app-extension-qcalendar/docs

Because this isn't part of the Material Design spec, it hasn't been included in the core component. I am not sure if this needs to be part of the date plugin...

nothingismagick avatar Jun 19 '19 11:06 nothingismagick

@nothingismagick he is referring to the date utils, not to a component.

rstoenescu avatar Jun 19 '19 12:06 rstoenescu