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

week of year berechnen #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

dasKamael
Copy link

@dasKamael dasKamael commented Mar 13, 2024

Calculation of week number in a year.

@@ -12,4 +12,32 @@ extension DateTimeExtension on DateTime {
bool get isSameYear {
return DateTime.now().year == year;
}

int get weekOfYear {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brauchen denke ich einen anderen Namen dafür. Wusste nicht direkt was damit gemeint ist

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weekOfTheYear oder andere vorschläge?

Copy link
Member

@JPM84 JPM84 Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.weekOfYear passt eigentlich, ist typisch z.B. in C#.

.week oder .day wäre noch schöner.

DateTime date = DateTime(year, month, day);

// Berechne die differenz zum Beginn des Jahres
int dayOfYear = date.difference(DateTime(year, 1, 1)).inDays + 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Würde zwei extensions hieraus machen.
.dayOfYear
.weekOfYear

Ein Test wäre hier zwingend für einen Merge.

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

Successfully merging this pull request may close these issues.

3 participants