Comments (5)
I have had a quick look through the source code and at the weekday function there is a little comment that says: // sunday is day 1, so the documentation is wrong. Sunday comes first in the index, but it is indexed at 1 and not at 0.
Today is Friday and that returns 6. I then tried weekday(now() + 86400); (the amount of seconds in a day) and it started returning 7. And weekday(now() + 172800); returns 1. So sunday = 1 and saturday = 7.
So to summarize if you want to have it 0 indexed (like I did) just subtract 1. This should either be updated in the documentation or fixed in the source code though, because in any case one of them is wrong... I believe this is a bug in the source, because it usually is the convention to return 0 for a sunday.
from time.
I'm an "intruder" here as I'm not currently using this library, but I think 0 = Sunday based weekdays (as used in the standard C time library) makes sense as you can perform "modulo 7" modular arithmetic on "number of days"
P.S.: ... and same goes for months: 0 = January ...
from time.
The readme says "day of the week (1-7), Sunday is day 1". The Arduino Playground documentation says "Day of the week, Sunday is day 1".
I've edited the playground page to now say "Day of the week (1-7), Sunday is day 1".
Sorry, this library is not going to make an incompatible change to 0-6 that will break so many existing programs. It's just not going to happen. Please stop asking. I do not care that the C library functions use a different convention. This library uses 1-7 and that range is well documented. If you want 0-6, you can subtract 1. Deal with it!
If there is any incorrect documentation, please tell me specifically where you see it? @pieman64 you wrote "but your notes indicate Sunday is 0". Where do you see this info?
from time.
Likewise, month() is not changing to zero based. @michaelmargolis (the original author of this library) and I talked about the API in person. This is a very well established library, since the very early days of Arduino, now used by many thousands of programs.
We are not going to make incompatible API changes. It does not matter if the standard C library follows a different convention. For incompatible API changes, the final definitive answer is no.
from time.
Thanks, I perfectly understand the rationale behind your choices (and agree, although this surely is not much important!)
from time.
Related Issues (20)
- Time.h and time.h issue on windows HOT 4
- v1.6.1 contains a breaking change for v1.6.0 clients; Semver suggests v2.0.0 tag. HOT 1
- Set system time so LittleFS can take over the real time
- error with DCF77 library: 'now' was not declared ..... in version 1.6.1 HOT 1
- TimeLib conflicts with NeoGPS library HOT 2
- 12/31/2097 HOT 1
- Issues compiling library with Arduino WEB IDE HOT 1
- Issue with setting time on arduino every HOT 1
- adjustTime increments a leap year when it shouldn't. HOT 1
- on pico set wire clock
- getNtpTime() doesn't handle zero from NTP server response HOT 1
- How to blink colon separator (:) every 500 millis..?
- Issue compiling on ESP32 with latest ESP32 library (2.0.6)
- convert timestamp to date and time ? HOT 1
- Combine hour() and minute() in HHMM format
- bug in minutesToTime_t macros HOT 2
- Epoch and Time offset HOT 3
- Time to deprecate TinyGPS
- How to disable setSyncInterval
- Error Date february 29/02/2024 but show 01/03/2024
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 time.