Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add weekday as unambiguous single letter abbreviation: MTWRFSU (capitalized) #936

Closed
eugenesvk opened this issue Jan 15, 2023 · 7 comments

Comments

@eugenesvk
Copy link

Three letters is too much space to convey that info in some of the dense table layouts

@djc
Copy link
Member

djc commented Jan 16, 2023

Is this style a part of other popular tools (like Unix' date)? I don't think I've run into these before, and I don't find the use of R for Thursday and U for Sunday intuitive at all, so I'm not inclined to include support for these in chrono.

@eugenesvk
Copy link
Author

Is this style a part of other popular tools (like Unix' date)? I don't think I've run into these before, and

Not done any extensive benchmarking as I don't see much value in being stuck in the bad designs of the past, but from some googling I've found that on a Mac https://en.wikipedia.org/wiki/Pmset has it
pmset [repeat, schedule] [sleep, wake, poweron, shutdown, wakeorpoweron] [<MTWRFSU> <date/time>]

(and some unsourced claims that it's "They seem universal to academia" in this wiki vital article)

I also use it in this great iStat Menus GUI app showing a calendar in your menu bar, where dense representation is paramount, so it looks like so in the menu:
d
and how you set in the options
d2

So it would be great if I could also use these design improvements in the infamous land of poor design :) — cli tools — that use this library to parse user input and format date output

I don't find the use of R for Thursday and U for Sunday intuitive at all

That's most likely because you're used to non-unique abbreviations MTWTFSS. R and U is the price you pay for uniqueness to avoid any confusion, but at the same time it's a much smaller price vs the much worse 1234567 (another common option is using two-symbol abbreviations like TuThSaSu). Also, that's very easy to get used to with a little practice

@pitdicker
Copy link
Collaborator

pitdicker commented Jul 20, 2023

Interesting to learn about the MTWRFSU 'convention'. As a non-native speaker I have never encountered it.

As I understand it the use is rare and mostly in tables to indicate something happens on multiples days that week.
For example in school history may be given on MWF. For the power schedule example on macOS it also makes sense to write MTWRF for work days. And it may be on top of calendars, similar to the ambiguous MTWTFSS.

Is there also common use for the letters as part of formatting a date?


That said, chrono does not have to support every odd convention under the sun.

Ans it is not especially hard to to implement this manually outside chrono:

    let mtwrfsu = ['M', 'T', 'W', 'R', 'F', 'S', 'U'];
    println!("{}", mtwrfsu[date.weekday().num_days_from_monday() as usize]);

It would be a cool example to add to Weekday::num_days_from_monday. See #1193.

@eugenesvk
Copy link
Author

And it may be on top of calendars
That would also be nice, though it's less of an issue for the calendars since you actually see the full range of days, which resolves the ambiguity

Is there also common use for the letters as part of formatting a date?
indicate something happens on multiples days that week.

or to indicate something happens on a single day, but without having to spell it out like in file managers or cli ls-like tools that display a list of files or as mentioned above menu indicators

Ans it is not especially hard to to implement this manually outside chrono:

and what do you implement if you're a consumer of a cli tool that uses this library (and doesn't add any text filters)? That's the power of defaults - they flow downstream

That said, chrono does not have to support every odd convention under the sun.

Sure, but before supporting every maybe there could be a support of any? There is currently no dense unique representation

@pitdicker
Copy link
Collaborator

Thank you for replying this quickly!

I have also seen your issue in lsd-rs/lsd#793. And I think it is cool. I've had my share of projects that try to squeeze every last byte out of some file, or make use of every tiny pixel.

and what do you implement if you're a consumer of a cli tool that uses this library (and doesn't add any text filters)? That's the power of defaults - they flow downstream

We don't really have defaults when it comes to formatting. Well, there are the ISO 8601, RFC 3339 and RFC 2822 formats. But otherwise it is up to the applications that use chrono. They can format the date however they like.

Sure, but before supporting every maybe there could be a support of any? There is currently no dense unique representation

There is, but it is numeric 😄.


Chrono has declined features in the past because they would not be generally useful enough.
If there where actual downstream projects requesting this feature we would more easily see they are boradly useful.

@eugenesvk
Copy link
Author

We don't really have defaults when it comes to formatting

%a | Sun | Abbreviated weekday name. Always 3 letters.
-- | -- | --

https://docs.rs/chrono/latest/chrono/format/strftime/index.html

these are what I meant by defaults

There is, but it is numeric 😄.

😄

But otherwise it is up to the applications that use chrono. They can format the date however they like.

Sure they can do anything and I wish there were more basic composable elements everywhere so that users can have the flexibility to format output however they like, but then it's much easier to use the "defaults" and expose them downstream, hence why these "defaults" are valuable, and why sticking with some clunky strftime convention has wider negative consequences (#19)

If there where actual downstream projects requesting this feature we would more easily see they are boradly useful

Or Chrono could show those projects how to do design better! That's part of the role of specialized libraries - to the be source of better practices within that specialized domain

@djc
Copy link
Member

djc commented Jul 24, 2023

Sorry, this isn't going to happen for now. I think the convention is not popular enough to support from within chrono, and all other things being equal I'd rather keep chrono smaller rather than add all functionality anyone asks for.

@djc djc closed this as not planned Won't fix, can't repro, duplicate, stale Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants