Skip to content

How to get current week of year? #209

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

Closed
chardskarth opened this issue May 25, 2022 · 2 comments
Closed

How to get current week of year? #209

chardskarth opened this issue May 25, 2022 · 2 comments

Comments

@chardskarth
Copy link

What's a counter part of the following code snippet?

Calendar.getInstance().get(Calendar.WEEK_OF_YEAR) // get current week of the year
@chardskarth
Copy link
Author

While waiting for a better solution, I'll settle with this dirty, foul workaround.

    constructor(): this(Unit.let{
        var now = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()).date
        val year = now.year
        var currentWeek = 0;
        while(now.year == year) {
            currentWeek++;
            now = now.minus(DateTimeUnit.WEEK)
        }
        currentWeek to year
    })

@dkhalanskyjb
Copy link
Collaborator

Duplicate of #129

@dkhalanskyjb dkhalanskyjb marked this as a duplicate of #129 May 27, 2022
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

2 participants