Skip to content

Conversation

dasKamael
Copy link

@dasKamael dasKamael commented Mar 13, 2024

Calculation of week number in a year.

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