Comments (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.
Also,
day_of_week
uses a "Sunday is the first day" approach since its using python %w
to determine.
from pendulum.
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.
Was there ever a resolution to this?
from pendulum.
dont think so
from pendulum.
Related Issues (20)
- pendulum PanicException on FreeBSD 14 HOT 4
- [Feature Request] Add strict mode for from_format()
- backports-zoneinfo does not compile on 3.10, and hard to package (pyinstaller, zipapp,...) HOT 3
- Bug / regression: Unable to parse string '031' with 'DDDD' format using Pendulum 3.0.0
- Regression - Inconsistent DBAPI serialization of pendulum datetimes
- Duration division, multiplication and mod broken for month lengths. HOT 1
- Default datetime string format changed in 3.0 release HOT 2
- Security issue or bug with pipenv ? HOT 1
- to_iso8601_string
- instance() fails for datetimes with pytz.FixedOffsets
- "import pendulum" causes unwanted import of pytest (presence of pytest in sys.modules often used to control Python behaviour) HOT 1
- MMM is not case-insensitive like Java
- If you have the /etc/timezone file set to a timezone string, pendulum.UTC has that timezone's utcoffset instead of None HOT 1
- in_words() exclude week
- timedelta additions to pendulum.DateTime HOT 1
- extreme slow down in `in_tz` after upgrading from 2.1.2 to 3.0.0 HOT 3
- Day of week constants
- pendulum.instance & dateutil.tz compatibility
- Localized Format LT inconsistent with leading zeroes
- Default string representation is not iso anymore HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pendulum.