Skip to content

Use Zero-Indexing for Weekdays #3

@LennartCode

Description

@LennartCode

Current State

Currently, there are 3 ways to index Weekday objects. iso and index both offer number Monday to Sunday 1..7 and us numbers Sunday to Saturday 0..6.

Proposal

I propose that index should number Monday to Sunday using 0..6, which would be different to the other two ways. This has the following advantage: Most cultures consider Monday the first day of the week and for mathematical reasons it is convenient to be able to access a first day of the week using the 0th index (like for us, the first day index is also 0).

While this is a breaking change, it does not influence the semantics of iso and us, which are presumably used by most people for accessing a weekday index for clarity, as suggested in the documentation.

Current Workaround

Either subtract 1 from the index on every operation or implement an extension type that uses an additional index implementation.

Somewhat related

On that note, it would also be nice to add dedicated methods for parsing Weekdays and a getter for accessing two-letter weekday shorthands. Those are minor quality of life features and unrelated to the actual proposal. I would be happy to contribute them if you deem them in the scope of the package though!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions