Giter Site home page Giter Site logo

Comments (5)

kokon avatar kokon commented on May 20, 2024 5

If anyone else stumbled onto this, I found that you can do:

>>> import pendulum
>>> dt = pendulum.now()
>>> dt
DateTime(2019, 12, 13, 9, 39, 20, 327110, tzinfo=Timezone(''))

>>> dt.start_of('week')     # Monday
DateTime(2019, 12, 9, 0, 0, 0, tzinfo=Timezone(''))
>>> pendulum.week_starts_at(pendulum.SUNDAY)
>>> dt.start_of('week')     # Sunday
DateTime(2019, 12, 8, 0, 0, 0, tzinfo=Timezone(''))

from pendulum.

yardensachs avatar yardensachs commented on May 20, 2024

Also,
day_of_week uses a "Sunday is the first day" approach since its using python %w to determine.

from pendulum.

sdispater avatar sdispater commented on May 20, 2024

First of all, the strftime method also works with pendulum:

>>> import pendulum
>>> dt = pendulum.create(2016, 10, 30)
>>> dt.strftime("%U")
'44'
>>> dt.strftime("%W")
'43'

You can use the set_week_starts_at() method on the Pendulum class to change the day a week starts at. It will not fix properties like week_of_year and day_of_week however.

I will see if I can fix this somehow.

from pendulum.

SeanDunford avatar SeanDunford commented on May 20, 2024

Was there ever a resolution to this?

from pendulum.

yardensachs avatar yardensachs commented on May 20, 2024

dont think so

from pendulum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.