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

(Friday + March) / April === 2.0 #51357

Open
LilithHafner opened this issue Sep 17, 2023 · 14 comments
Open

(Friday + March) / April === 2.0 #51357

LilithHafner opened this issue Sep 17, 2023 · 14 comments
Labels
domain:dates Dates, times, and the Dates stdlib module kind:bug Indicates an unexpected problem or unintended behavior

Comments

@LilithHafner
Copy link
Member

This is too permissive.

@LilithHafner LilithHafner added kind:bug Indicates an unexpected problem or unintended behavior domain:dates Dates, times, and the Dates stdlib module labels Sep 17, 2023
@LilithHafner LilithHafner added this to the Potential 2.0 milestone Sep 17, 2023
@Seelengrab
Copy link
Contributor

Seelengrab commented Sep 17, 2023

This is because none of the months have a proper type - they are literally numeric constants as magical numbers:

"""
January
The first month of the year.
# Examples
```jldoctest
julia> January
1
```
"""
const January = 1

julia> January
1

julia> January |> typeof
Int64

@jacobusmmsmit
Copy link
Contributor

I can't think of any languages that have months and weeks be treated as integers by default.
Is there a precedent for this in a language someone knows? Is it useful in any applications?

@timholy
Copy link
Sponsor Member

timholy commented Sep 17, 2023

Presumably they should be @enums

@llbit
Copy link

llbit commented Sep 18, 2023

I can't think of any languages that have months and weeks be treated as integers by default. Is there a precedent for this in a language someone knows? Is it useful in any applications?

It could be useful for iterating over a range of months, for example August:December

@Seelengrab
Copy link
Contributor

That can easily be accomodated by another approach as well. Ranges are not exclusive to numbers; 'a':'z' works too, for example, which has an analogous situation.

@KristofferC KristofferC removed this from the Potential 2.0 milestone Sep 18, 2023
@KristofferC
Copy link
Sponsor Member

KristofferC commented Sep 18, 2023

I don't think fixing this has to be breaking.

Although looking at it a bit more, it seems that returning integers for months (e.g. in the month function) is used in quite a lot of places.

@jacobusmmsmit
Copy link
Contributor

jacobusmmsmit commented Sep 18, 2023

How about making Dates an upgradeable stdlib?

I mean, this kinda misses the point a little as users have to opt in when the problematic constants are already defined.

@JeffBezanson
Copy link
Sponsor Member

I don't think this can be considered a bug --- Dates exports these constants and the design, clearly, was to make them just integers. You can certainly disagree with that design but changing it now would cause bugs.

@Seelengrab
Copy link
Contributor

Right - hence the requirement to do this in a major version bump of the stdlib (which need not coincide with a major version bump of Julia, if I'm not mistaken).

@simonbyrne
Copy link
Contributor

See #19210 (and #19221, which was folded into it)

@Seelengrab
Copy link
Contributor

Seelengrab commented Sep 25, 2023

A bit depressing that #19210 has been open for numerous breaking releases now 😬

@KristofferC
Copy link
Sponsor Member

Dates could be moved to an upgradable stdlib and there could be a breaking version made there maybe?

@jacobusmmsmit
Copy link
Contributor

The only potential problem I see with upgradeable stdlibs is backporting bugfixes and maintaining the non-breaking Dates package. Would everyone who just uses Julia 1.X without touching Dates be left bugfixless?

@Seelengrab
Copy link
Contributor

Has seen Dates that much movement/fixes in the past that this is a concern? Most Dates stuff seems recent and about the core design of the package, not just related to easily fixable bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:dates Dates, times, and the Dates stdlib module kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

8 participants