- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
"I said I wanted pretty week code, not pretty weak code!"
Admin
I don't see any reason why this code wouldn't work in leap years. Leap years don't affect the flow of the days of the week -- it's not like we have two Tuesdays in a row in leap years.
But it WON'T work on the days when we transition to or from Daylights Savings Time. Two days a year are NOT 24 hours long. There is one that is 23 hours and one that is 25 hours.
Admin
Admin
Among the funny things here is that the problem with the commented-out code has nothing to do with rolling over month boundaries. The comment indicates he wants "next Tuesday", but the code will give the upcoming Tuesday if that starting date is Sunday or Monday and the preceding Tuesday if the starting date is Wednesday through Saturday. It looks like he wrote code with a bug and when it didn't work, jumped to the conclusion that the library code had a bug.
Admin
Advanced lessons in computing, please learn:
I'm sure there are others, and they will be added later. See the followons.
Admin
If you mean that a holiday is on, say, "Monday", rather than "the second day of the week", I guess that's true.
All told, I'm not sure what your point is.
Where it really matters what the "first day of the week" is comes when you say something like "we will do that next week". You have to know when a week starts and ends to properly interpret the date referenced by such a statement.
Admin
Come on, be serious. The real rule is this: If the 28th day of February in a leap year is Monday, then the 1st day of March in that same year is Tuesday. The day of week for the 29th of February is FILE NOT FOUND.
Admin
GIGO!
Admin
Admin
[quote user="gnasher729"][quote user="pscs"][quote user="olaf"]In Christian, Islamic and Jewish tradition, Sunday is the first day of the week.[/quote] God created the universe in six days, and the seventh day was a day of rest. Sunday = seventh day in Christian tradition. And think about the word "weekend". [/quote]
Actually, this is a subtle point that has led to the creation of the religion known as Seventh-Day Adventists. The idea is that the Jewish tradition actually holds Saturday as the day of rest, and due to some date issues with Christ's rising the early Christian church decided that Sunday was a more memorable day than Saturday. In one of the Gospels there's a bit about how on that day "It was then the first day of the week." Add that to the dating of Easter Sunday on... well... Sunday and you get that at the time of writing, Sunday was considered the first day of the week.
Admin
[quote user="someguy"][quote user="gnasher729"][quote user="pscs"][quote user="olaf"]In Christian, Islamic and Jewish tradition, Sunday is the first day of the week.[/quote] God created the universe in six days, and the seventh day was a day of rest. Sunday = seventh day in Christian tradition. And think about the word "weekend". [/quote]
Actually, this is a subtle point that has led to the creation of the religion known as Seventh-Day Adventists. The idea is that the Jewish tradition actually holds Saturday as the day of rest, and due to some date issues with Christ's rising the early Christian church decided that Sunday was a more memorable day than Saturday. In one of the Gospels there's a bit about how on that day "It was then the first day of the week." Add that to the dating of Easter Sunday on... well... Sunday and you get that at the time of writing, Sunday was considered the first day of the week.[/quote]
Just an addendum: Jewish tradition holds that Saturday is the day of rest because it is the weekly anniversary of the seventh day of creation, on which the creator rested.
Admin
I don't know what Western country you are from, but here in the states we start our weeks on Monday. And from my experience working with people in Europe and Canada so do they. In fact, even working with contractors from eastern Asian countries their days start on Monday as well.
Admin
That's awesome. It's also friendly for changing when number of days in a week change.
Admin
I don't know what kind of a sadist decided that the week should start on Monday. It makes it hardly worth getting out of bed. The week should really start on Friday, then you can work one day and immediately get two days off. This would be much better, in my opinion.
Admin
Admin
In the beginning Java was created. This has made a lot of people very angry and been widely regarded as a bad move.
Admin
Admin
No, no. It's much better the way it is now. One day off at the start of the week, and one day off at the end.
Admin
'end' does not always mean 'opposite of beginning.' Think of bookends. The devices sit at both ends of a row of books. "both ends."
"week starts on monday"... well, the "work week" starts on monday for those that work monday through friday (or through whenever). There are plenty of people in the US who work different hours. And there are plenty of people int he US who count "sunday" as the start of the week. In fact, look at a typical calendar sold in the US and you'll see weeks starting on sunday and ending on saturday - sunday starts each row and saturday ends each row.
Admin
Admin
And now "end" is the opposite of "end." Awesome. We're brilliant here.
yes, I'm being pedantic, but I'm no less deconstructive than the other comments here
Admin
Provided you're running the code no earlier than when the clocks change, and more than an hour before midnight, you're still OK.
The better approach would be to adjust the base time to midday before adding days; then the code is fine no matter when it's run. Five microseconds to midnight excepted, of course.
Admin
Ah. You expect people to respond to what you said, rather than to something rather like what you said that suits their argument better.
You must be new here. Don't panic - you'll get used to it.
Admin
It's hardly going to matter, the s/w's not going to be around long enough to last till the next leap year anyway. That's like 3 years away. Nearly. We'll have upgraded way before then.
Admin
I have a degree. I must be able to make a nice simple date thingummy to do what I want
switch you sarcasm detector on
Admin
I laugh when I see people do wierd things like use an existing Date class, then extract all the bits (Day, Month year) play with them, and then re-create a date. Seems to defeat the purpose a little, but I spose they're 1/2 way there
Admin
Admin
Admin
** yup, they is boring enough to have first-day (pirmdiena), second-day (otradiena), third-day (trezhdiena), fourth-day (ceturdiena), fifth-day (piekdiena), sizth-day (sezdiena) and holy-day (Svetdiean))
Admin
i think they could've just used a slider to show the current week's window so you can work out the tuesday in the week
Admin
Admin
Admin
how long is a piece of string? Twice the distance from one end to the middle
Admin
Actually that's incorrect. The early Christians purposely set Sunday as a day of celebration of Christ's rising, and explicit rejection of the need to honor the Jewish Shabbat (which runs from sunset Friday to sunset Saturday), demonstrating that the rules of the Old Testament were no longer controlling. As Christ said, "The law was made for man, not man for the law, the Sabbath was made for man, not man for the Sabbath".
Admin
TRWTF is using Java.
Admin
Actually, that is incorrect. The law was made by man, just like christ, god, the shabbat, the old testament, and every other crackpottery you just mentioned where created by man.
We're talking about technology here. The imagination of a group of jews ~1800 years ago has nothing to do with anything.
Admin
a unit test would be useful.
Admin
Admin
Admin
Welcome to the Daily Wednesday Thursday Friday.
Admin
According to this list, the majority of countries actually defines Monday as the starting day (add both sections of Sunday start vs both sections of Monday start).
If you weigh by population, Sunday might still win because you have China, India and the US in there.
Admin
The beginning is the end is the beginning
Admin
I like how code that is not tested to work in leap years was still committed. After all, only 25% of years are leap years, who cares about those?
Admin
All rejoice then, in the new 'java.time' package in Java 1.8.
Maybe.
Admin
[quote user="Coyne"][quote user="someguy"][quote user="gnasher729"][quote user="pscs"][quote user="olaf"]In Christian, Islamic and Jewish tradition, Sunday is the first day of the week.[/quote] God created the universe in six days, and the seventh day was a day of rest. Sunday = seventh day in Christian tradition. And think about the word "weekend". [/quote]
Actually, this is a subtle point that has led to the creation of the religion known as Seventh-Day Adventists. The idea is that the Jewish tradition actually holds Saturday as the day of rest, and due to some date issues with Christ's rising the early Christian church decided that Sunday was a more memorable day than Saturday. In one of the Gospels there's a bit about how on that day "It was then the first day of the week." Add that to the dating of Easter Sunday on... well... Sunday and you get that at the time of writing, Sunday was considered the first day of the week.[/quote]
Just an addendum: Jewish tradition holds that Saturday is the day of rest because it is the weekly anniversary of the seventh day of creation, on which the creator rested.[/quote]
Of course the real reason why the day of worship was moved to Sunday is that Romans literally worshiped the Sun on Sundays, and it was pretty much impossible to convince new Christians to forgo their flashy Sunday rituals for the boring Sabbath, so the practical minds at the church thought they could keep the 4th commandment while attracting new converts by merging both celebrations.
For bonus trivia points: a similar reason explains why Jesus' birthday was declared to coincide with the winter solstice.
Admin
She is doing well, but her dates keep getting messed up...
Admin
TRWTF that according to that list Hungary is broken on Windows 2k (Wednesday as the first day? come on...)
On the other hand Monday in Hungarian (hétfő) actually means the "head of the week".
Admin
Centuries not evenly divisible by 400 are not leap years.
Admin
Admin
OK, so TRWTF is numbering days beginning from 1 instead of holy 0 ;-)