To get week-number from a date
-
Hi,
how I do it, get week-number from a date on micropython?
I'used utime but not found!
Somebody kindly can help me?Many thank
-
It is indeed not built in by default.
I suggest you look at something like this? https://github.com/micropython/micropython-lib/blob/master/datetime/datetime.py. You can upload this in the lib folder and include it likeimport datetime. This will be similar to the datetime Python library. -
This post is deleted! -
@Gijs said in To get week-number from a date:
import datetime
Hi Giijs , Many thanks, I not can't writting on lopy 73kb it's very big...
-
Sorry, I did not notice that!
You could take a look at how they create the weeknumber and copy only that part.
Best,
Gijs -
@StefanoF Use frozen modules, building your firmware for LoPy v1.
-
@StefanoF You could try time.localtime()[7] which gives you day of the year then calculate week number from that? For example
week_number=int(time.localtime()[7]/7)should give weeks 0-51
-
@kjm But will that always work though? I have a feeling this might break in some edge cases (week 53, new year week not starting on monday) or is that just in my head?
Gijs
-
@Gijs Ask me again new year's day!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login