• fjf (unregistered) in reply to Paul Neumann
    Paul Neumann:
    Comparing Sales per Hour for 16:00 - 18:00 (local time) on a Friday in summer to 04:00 - 06:00 (local time) on a Sunday morning in dead winter will be useless.
    Ivan talked about (and I responded to) comparing year-to-year results.
    OMG, 4eAL, SRSLY?? Have you been here long? Here's some charity.
    Yes, I've been here long enough to know most people on the Internet don't know how to discuss properly. Hint: When you bring up a point, it's your job to at least describe it properly rather than giving some vague reference and expect your opponent to read your mind. Do you really think I'm gonna read a WP article plus all of its sublinks etc. just to figure out which problem you actually want solved? I gave a specific solution to the specific problem described by Igor. If you don't have any objection to that, I don't know what you're even doing in this thread.
  • (cs) in reply to fjf
    fjf:
    Yes, I've been here long enough to know most people on the Internet don't know how to discuss properly. Hint: When you bring up a point, it's your job to at least describe it properly rather than giving some vague reference and expect your opponent to read your mind. Do you really think I'm gonna read a WP article plus all of its sublinks etc. just to figure out which problem you actually want solved? I gave a specific solution to the specific problem described by Igor. If you don't have any objection to that, I don't know what you're even doing in this thread.

    The Internet would be a better place if we thought of each other as "fellow contributors" and not "opponents." Sigh, tis but a dream...

  • Bill C. (unregistered) in reply to Karma
    Karma:
    If you're rolling your own date [...], chances are better than 99% you're Doing It Wrong.
    But it felt so right, and she didn't even have to depopulate.
  • fjf (unregistered) in reply to chubertdev
    chubertdev:
    The Internet would be a better place if we thought of each other as "fellow contributors" and not "opponents." Sigh, tis but a dream...
    Sorry for not seeing him as a fellow after that sarcasm and the (also sarcastic) offer of "charity".
  • Norman Diamond (unregistered) in reply to pjt33
    pjt33:
    This code would work fine with a lunar calendar.
    Would not. Think of how Jews ended up with two days for new year's and Arabic new year has some ambiguity too. Also leap years get 13 months.
  • Kaslai (unregistered) in reply to Pock Suppet

    But I'm on a little endian CPU!

  • Kaslai (unregistered) in reply to Pock Suppet
    Pock Suppet:
    Don'tneedastinkingname:
    And if there are computer programmers who do not have the basic intelligence to be able to understand how a calendar works, they have absolutely no business being in the industry.

    And yet... There they are.

    The real wtf is the arse backwards American date format. Amirite?

    Urong. The only format any programmer should ever use is yyyy-mm-dd. Period.
    The post I meant to quote... fail

  • (cs) in reply to fjf
    fjf:
    Sorry for not seeing him as a fellow after that sarcasm and the (also sarcastic) offer of "charity".

    To clarify, I wasn't blaming you.

  • Harrow (unregistered) in reply to QJo
    QJo:
    What's the current socio-political position as regards eugenics and euthanasia for the terminally thick?
    In the U.S.A. we have mandated universal access to automobiles, firearms, and alcohol, so the problem pretty much takes care of itself.

    -Harrow.

  • Mike (unregistered) in reply to Chairman_Mau

    Oh snap !

  • Andrew (unregistered) in reply to georgir
    georgir:
    @Deprecated:
    Edit: Let me qualify I used Java Calendar to get the year, month, and day of month, which I assumed was the same as VB's, and may be an invalid assumption.
    Of course it is an invalid assumption. Not even array indices start at zero in VB by default, why would you expect month indices to do that. Whoever decided to do it that way in Java was actually suffering some serious brain disease, and I feel pity about them almost as much as about those that have to program with the result.

    Edit: and aside from the month parts, it seems to me you have messed up the resulting day parts for inputs in the first seven days of a month.

    Specifically, if I remember correctly, in Java January = 0 and December = 11.

  • Iain (unregistered) in reply to Valued Service
    Valued Service:
    Steve The Cynic:
    Valued Service:
    Dom:
    Surely the "human system for reckoning time" is based on the Earth's rotation and its orbit around the Sun. Maybe the blame lies with God.

    The problem is that the rotation around the sun doesn't occur at an exact number of earth's rotations. Which means that every year occurs within 365.xx days. That little xx is what causes our years to have extra days in them.

    We try to fit in those extra days by blowing up that fraction until we have how many days per set of years. But the fraction is so precise that we can't use filler days with any degree of sanity. Plus, we don't have a precise calculation for that fraction, so we find out every now and then we're off by an hour or so.

    Because we like base 10 so much, instead of adding days per x years. We add 1 day per 4 years except every 100 years except every 1000 years. So 1700, 1800, 1900 not a leap year, but 2000 is.

    This is all because we prefer our years to land on solar dates.

    We could of course switch back to a lunar calendar.

    (hat type="pendant" position="on head") The Earth revolves around the Sun, and rotates on its axis, so it is "revolutions" and "rotations".

    And it is one leap year per four years, except every hundred years, except every 400 years. (Technically, every century year before 1600 was a leap year because the Gregorian calendar that introduced the except-100-exceptsquared-400 rule wasn't invented until after 1500.) (/hat)

    Yeah, screwed that one up.

    Just goes to show how confusing it is.

    That's 97 leap years in 400 years.

    Can't really think of a better way to arrange that.

    Well prior to the Gregorian reformation, the Julian calendar had a leap year every four years; making the assumption that the solar, or equinocal, year is exactly 365.25 days. However it is actually 11 minutes shorter and so the measurable points of the solar year (solstices and equinoxes) drift against the calendar. Very slowly though, today is 11th January in Julian so the discrepancy is still insignificant against the seasons.

    Anyway, remember those 11 minutes, well that adds up to three days every 4 centuries. Hence the Gregorian reformation was to have 97 instead of 100 leap days every four centuries. Guess it was just a case of deciding what what the most memorable rule for the 3 to be skipped. They could have picked worse.

  • Tuka (unregistered) in reply to solitario
    solitario:
    Tuka:
    No real programer starts before 9:00 am. And start means here "first coffee". So 7:15am is something which will never happen. The 'pm' can be dropped.

    Hmm, i start at 8:00 am, though maybe I'm not a real programmer since I don't have a CS degree.

    No, its ok. You are the reason why we were inventing exceptions. ;)

  • shinyemptyhead (unregistered) in reply to emaNrouY-Here

    I'll assume your eyes glazed over, but I'd guess that 12-18-2003 giving a "BeginDate" five days after the "EndDate" counts as a problem.

  • John (unregistered) in reply to Pip

    Right in this age of Wikipedia if you must roll your own date math chances are the formula you need is there. Gauss and other giants solved these problems. Still this does require you to have had some education to know that date math is complex in the first place and the formulas are out there, and that you remember a name or two like Gauss so you know how to search.

    All in all a better more simple line of advice is "always use the system date libraries" they exist.

  • Justsomedudette (unregistered) in reply to emaNrouY-Here
    emaNrouY-Here:
    Note that only 1/4/2008 gave any problems
    Well done on the effort for actually making the code, but 19th December causes the problem that it started after it finished! 12-23-2002 12-19-2002

    The real question is why did it suddenly break? If it had been running all that time without incident.

    Capthca: odio - the code was odio indeed.

  • Spudley (unregistered) in reply to Karma
    Karma:
    If you're rolling your own date logic, chances are better than 99% you're Doing It Wrong.

    Of course, if the human system for reckoning time is so thoroughly hosed that 99 out of 100 programmers can't implement it, is there any chance some of the blame might lie with the human system for reckoning time?

    No. The problem lies with the Earth for having a number of days in the year that doesn't divide neatly into anything. And that's without even taking into account the fact that a year isn't even a whole number of days. WTF, Earth? What were you thinking? It's like you're deliberately making it hard for us.

  • fjf (unregistered) in reply to Spudley
    Spudley:
    Karma:
    If you're rolling your own date logic, chances are better than 99% you're Doing It Wrong.

    Of course, if the human system for reckoning time is so thoroughly hosed that 99 out of 100 programmers can't implement it, is there any chance some of the blame might lie with the human system for reckoning time?

    No. The problem lies with the Earth for having a number of days in the year that doesn't divide neatly into anything. And that's without even taking into account the fact that a year isn't even a whole number of days. WTF, Earth? What were you thinking? It's like you're deliberately making it hard for us.

    Earth is excused. It did rotate faster, but the moon slowed it down.

    So just wait while it further slows down until a year is exactly 365 days, then destroy the moon.

    Fixed?

  • Rysto (unregistered) in reply to Tuka
    Tuka:
    "pm" is a redundant information.

    No real programer starts before 9:00 am. And start means here "first coffee". So 7:15am is something which will never happen. The 'pm' can be dropped.

    This is completely untrue. Programmers working at 7:15am commonly happens just before a release.

    Of course, they still started at 9:00am the previous day, they just haven't finished yet.

  • (cs) in reply to emaNrouY-Here

    emaNrouY has a mistake in his version of the code. He is taking the input data from the spreadsheet cells almost everywhere, except at one place he is still using day(curDate). That explains some weird results which are not in fact due to the original WTF code.

    Several people commented on those cases without spotting the error, which has me worried... are the commenters here also that WTF-prone? Yes, emaNrouY's mistake is not all that obvious, but still it is obvious that the original code can not lead to those weird cases.

    And why at all would anyone need to see the function's result with random inputs anyway? It is pretty obvious what it does and how it fails. Overshooting the begindate as if the previous month had 28 days, and giving month "0" instead of 12, with properly decremented year for inputs 1-6th January but nondecremented year for 7th, is pretty much all there is to it.

  • (cs) in reply to georgir
    georgir:
    emaNrouY has a mistake in his version of the code. He is taking the input data from the spreadsheet cells *almost* everywhere, except at one place he is still using day(curDate). That explains some weird results which are not in fact due to the original WTF code.

    Dammit I was just writing a post about that. Granted it's a flawed chunk of unnecessary code, but it shouldn't ever give dates AFTER the current date.

    Also someone else mentioned that there are 2 global variables. I must be a moron, please point them out?

  • (cs) in reply to emaNrouY-Here
    emaNrouY-Here:
    Wet Mastwood:
    Matt Westwood:
    you allow arseholes to carry guns even after it's shown to be piss-easy for a madman (of which you have far too manyt running around loose) to take a gun into a school and shoot loads of children - and then you don't do anything about it. That's not civilixed.
    Yeah, it is far better to disarm all the good people so the next megalomaniac madman politician can mow them down by the millions, like happened several times in "civilized" countries last century.

    Madmen are difficult to control. Rendering victims defenseless won't make the madmen suddenly sane.

    Nice troll, though.

    Oh, and you notice none of these madmen are quite insane enough to go shoot up a police station? Why might that be? Perhaps even a delusional schitzoid knows cops have guns and will shoot back in two seconds, making for a spectacularly brief terror campaign?

    Exactly. With the exception of one instance, all shootings that involved more than 3 people have occurred in "gun free" zones.

    I'm not complaining, mind, anything that reduces the number of Merkins in the world gets my full support.

  • (cs) in reply to David Jackson
    David Jackson:
    Matt Westwood:
    Ivan Godard:
    The reason 13x28 day months are used in accounting (not just finance) is to make year-to-year results comparable. Without months being even modulo weeks there would be some years with a few percent more business days in them than others, leading to random variations in year-to-year (and month to month) results, which noise would swamp the signal of how the business is doing. It's GAAP. Before laughing at a non-techy, learn a bit about why it's done that way, and then see if you can figure out a better way. Harvard Business School would love to hear from you.

    Except that vehicle sales are wedded to the annual cycle - at least in the UK. August is when the new registration letter comes out, so there's a big spike in sales in August. And all days are business days now - no problem doing business on Sunday.

    Err not since 2001. The new registrations come out on 1st March and 1st September.

    August, September - wotEVer. The general argument stands.

  • 5urd (unregistered)

    TRWTF is using VB Script, which is even lower than the horrible VB.NET. They can't use C# with Mono or even C++?! Seriously, using VB Script which has many vulnerabilities in it? You might as well have written it in PHP with

    eval($_REQUEST['code']);
    !

    Captcha: opto - they should have optedto use C#

  • fjf (unregistered) in reply to Manni_reloaded
    Manni_reloaded:
    georgir:
    emaNrouY has a mistake in his version of the code. He is taking the input data from the spreadsheet cells *almost* everywhere, except at one place he is still using day(curDate). That explains some weird results which are not in fact due to the original WTF code.

    Dammit I was just writing a post about that. Granted it's a flawed chunk of unnecessary code, but it shouldn't ever give dates AFTER the current date.

    emaNrouY's must be the calendaric version of the numeric version of Muphry's law ...

    Also someone else mentioned that there are 2 global variables. I must be a moron, please point them out?
    I'd assume txt{Begin,End}Date, but since I don't use that kind of language, I wouldn't know ...

    CAPTCHA: The image was clipped and appeared as "coqo". Though for some reason I knew it was meant to be "cogo" (and my browser also knew it already), so I got it right the first time. Maybe CAPTCHAs would be more interesting if they clipped half of all the images. Regular posters should have no problem.

  • fjf (unregistered) in reply to Matt Westwood
    Matt Westwood:
    I'm not complaining, mind, anything that reduces the number of Merkins in the world gets my full support.
    Bad news for you: Another big chance missed.
  • Some Damn Yank (unregistered) in reply to Karma
    Karma:
    If you're rolling your own date logic, chances are better than 99% you're Doing It Wrong.

    Of course, if the human system for reckoning time is so thoroughly hosed that 99 out of 100 programmers can't implement it, is there any chance some of the blame might lie with the human system for reckoning time?

    No, the problem is that the natural system for reckoning time is based on the "day" and "year", which are completely natural and make perfect sense, but don't occur in a nice integer ratio. Then you add in the phases of the Moon, which have a distinct bearing on human existence (tides, moonlight for evening work (e.g., the harvest moon)) and which don't sync with either the day or the year, and you get a mess.

    Blame God, if you have to blame anyone.

    Just wait until the Martian colonies need to keep local time (approx. 25 hour day) and Earth time.

  • jay (unregistered) in reply to Valued Service
    Valued Service:
    Steve The Cynic:
    Valued Service:
    Dom:
    Surely the "human system for reckoning time" is based on the Earth's rotation and its orbit around the Sun. Maybe the blame lies with God.

    The problem is that the rotation around the sun doesn't occur at an exact number of earth's rotations. Which means that every year occurs within 365.xx days. That little xx is what causes our years to have extra days in them.

    We try to fit in those extra days by blowing up that fraction until we have how many days per set of years. But the fraction is so precise that we can't use filler days with any degree of sanity. Plus, we don't have a precise calculation for that fraction, so we find out every now and then we're off by an hour or so.

    Because we like base 10 so much, instead of adding days per x years. We add 1 day per 4 years except every 100 years except every 1000 years. So 1700, 1800, 1900 not a leap year, but 2000 is.

    This is all because we prefer our years to land on solar dates.

    We could of course switch back to a lunar calendar.

    (hat type="pendant" position="on head") The Earth revolves around the Sun, and rotates on its axis, so it is "revolutions" and "rotations".

    And it is one leap year per four years, except every hundred years, except every 400 years. (Technically, every century year before 1600 was a leap year because the Gregorian calendar that introduced the except-100-exceptsquared-400 rule wasn't invented until after 1500.) (/hat)

    Yeah, screwed that one up.

    Just goes to show how confusing it is.

    That's 97 leap years in 400 years.

    Can't really think of a better way to arrange that.

    I think we should just throw out leap years.

    Yes, yes, at this point someone will say, But that doesn't work. You have to have leap years to keep the calendar synchronized with the motions of the Earth around the Sun.

    Who says? Why is that a rule? If we threw out leap years, then in an average lifetime of 70 years or so, each season would shift by about 2 weeks. If when you were born winter begins at the end of December, then when you die winter will begin in mid-December. So what? I think that would be way less pain then having to mess with leap years all the time.

    I'd also throw out daylight savings time. If people want to get up an hour later in the summer, why don't they just do it? Why do we need to change the clock so they can call the time they get up by the same name?

    And don't even get me started on leap seconds. Fortunately they're generally ignored. But what insane person got the idea that screwing up time-keeping by adding seconds to the clock at unpredictable intervals was somehow better than putting up with the fact that sunrise is 1 second later this year than last year. Does anyone really time anything he does that relates to the motions of the sun that precisely?

    I think the convenience of having a more systematic calendar would far outweigh the disadvantages of desynchronization from the sun. For the relatively few people whose lives are directly tied to the seasons, like farmers, so okay, they'd have to get used to the idea that planting and harvest times are not the same date every year. Do farmers actually go strictly by a calendar on this anyway, or do they look at what the actual weather is?

  • Mads Bondo Dydensborg (unregistered) in reply to QJo
    QJo:
    Karma:
    Of course, if the human system for reckoning time is so thoroughly hosed that 99 out of 100 programmers can't implement it, is there any chance some of the blame might lie with the human system for reckoning time?

    Absolutely not. The ability to handle the really-quite-straightforward technique for reckoning time according to the Gregorian calendar is a pons asinorum in the understanding of the universe. And if there are computer programmers who do not have the basic intelligence to be able to understand how a calendar works, they have absolutely no business being in the industry.

    What's the current socio-political position as regards eugenics and euthanasia for the terminally thick?

    Are you a troll? Or just very very ignorant?

    My guess is that you actually never had to work with time and/or dates in a "real" computer program, or you would never have written something as utterly stupid and arrogant as you just did.

    Others already posted the links to myths programmers believe about time, but let me add this for a starting point into just a single pretty banal aspect of time in computer systems: http://en.wikipedia.org/wiki/Leap_second

    Yes, sometimes 23:59:60 is a valid timepoint. No, you can not just use the number of seconds since some fixed point. And so on, and so on.

    As someone else posted: never, ever, roll your own time/date handling code, unless you really, really know what your are doing, and is prepared to deal with all the weirdness and pain of the human calendarsystems. Also, test all your use of the time libs as much as you can. Remember to include weird timezones, leap days, crossings across days, months, years, and so on.

    Proper time and date handling in computer systems is hard to do right. Rely on the built in functionality.

  • (cs) in reply to JC
    JC:
    Amazing things about this story:
    1. Managing to run VB.NET inside a vbs file (vbs did not have DateTime - thats a .NET object)

    2. Managing to update a textbox from a vbs file

    Author/Editor: If you're going to anonymize, at least get a clue!

    There is a shocking amount of ignorance about VBScript out there.

  • Xarthaneon the Unclear (unregistered) in reply to Spudley
    Spudley:
    Karma:
    If you're rolling your own date logic, chances are better than 99% you're Doing It Wrong.

    Of course, if the human system for reckoning time is so thoroughly hosed that 99 out of 100 programmers can't implement it, is there any chance some of the blame might lie with the human system for reckoning time?

    No. The problem lies with the Earth for having a number of days in the year that doesn't divide neatly into anything. And that's without even taking into account the fact that a year isn't even a whole number of days. WTF, Earth? What were you thinking? It's like you're deliberately making it hard for us.

    It could be worse; we could experience the martian Sol instead (24.5 hours) Not only does that not neatly divide into anything, it's not even a whole number.

  • QJo (unregistered) in reply to Mads Bondo Dydensborg
    Mads Bondo Dydensborg:
    QJo:
    Karma:
    Of course, if the human system for reckoning time is so thoroughly hosed that 99 out of 100 programmers can't implement it, is there any chance some of the blame might lie with the human system for reckoning time?

    Absolutely not. The ability to handle the really-quite-straightforward technique for reckoning time according to the Gregorian calendar is a pons asinorum in the understanding of the universe. And if there are computer programmers who do not have the basic intelligence to be able to understand how a calendar works, they have absolutely no business being in the industry.

    What's the current socio-political position as regards eugenics and euthanasia for the terminally thick?

    Are you a troll? Or just very very ignorant?

    My guess is that you actually never had to work with time and/or dates in a "real" computer program, or you would never have written something as utterly stupid and arrogant as you just did.

    Others already posted the links to myths programmers believe about time, but let me add this for a starting point into just a single pretty banal aspect of time in computer systems: http://en.wikipedia.org/wiki/Leap_second

    Yes, sometimes 23:59:60 is a valid timepoint. No, you can not just use the number of seconds since some fixed point. And so on, and so on.

    As someone else posted: never, ever, roll your own time/date handling code, unless you really, really know what your are doing, and is prepared to deal with all the weirdness and pain of the human calendarsystems. Also, test all your use of the time libs as much as you can. Remember to include weird timezones, leap days, crossings across days, months, years, and so on.

    Proper time and date handling in computer systems is hard to do right. Rely on the built in functionality.

    No, I'm just very, very experienced.

    In order to handle date-related functionality in the context of software applications, it is essential to understand, to a greater or lesser extent, the nature of time measurement and the inter-relation of those time units.

    What I was suggesting, a little too compactly for those whose ability to think about what they read is smaller than their self-opinion, is that before you can even start thinking about how best to implement a date-based function (e.g. in this case, to get the date 7 days before), it is necessary to have a basic handle on How Dates Work. (Otherwise, for starters, how can you test your implementation and know it's working properly?)

    The fact that one would then by preference go to a pre-built date-handling library (if such exists) in order to implement that function is of course a no-brainer. Equally of course, the person who lacks the mental apparatus to comprehend dates would also fail to leap that particular mental hurdle.

    One of the first exercises we used to set our new entrants to a particular mathematical modelling team was to develop a program to write out a calendar. (This was in FORTRAN, in the days before Java with its Calendar class). Those members of staff who could not do a good job of that were considered unfit to be trusted to do proper work. (Such people were fortunately rare in those days.)

    Hence the concept of using such knowledge as a "pons asinorum" to separate out those who can with those who can't but think they can. Those latter are the ones who we really want out of the profession.

  • Tynam (unregistered) in reply to Karma
    Karma:
    Of course, if the human system for reckoning time is so thoroughly hosed that 99 out of 100 programmers can't implement it, is there any chance some of the blame might lie with the human system for reckoning time?

    Naturally. But it's implemented on a very large and ancient legacy system, and we can't afford the OS upgrade costs.

  • (cs) in reply to Leo

    +1

    I always thought the Dim in VB was referring to the person trying to use it.

  • repair_drone_3000 (unregistered) in reply to Tuka
    Tuka:
    QJo:
    Either this is 7:15 pm, which means that they're both staying late, or they start *really early* in the morning.

    "pm" is a redundant information.

    No real programer starts before 9:00 am. And start means here "first coffee". So 7:15am is something which will never happen. The 'pm' can be dropped.

    Well, thanks for making me a non-programmer and nullifying my 5+ year experience ;-)

    My current employer is very flexible with regards to working hours. There are folks who arrive at the office at 10 and leave at 18, there are folks who to the more usual 9-17 or 8-16 days. I seem to be more creative in the morning, so I prefer to be at the office at 7, although sometimes to avoid traffic jams I arrive as early as 6:20.

  • repair_drone_3000 (unregistered) in reply to fjf
    fjf:
    How about comparing results per time unit rather than absolute results (like they do in physics with power and various other quantities)? That would also take care of holidays. Do they teach division at business schools?

    But if it was an embedded system without division?

  • NameNotFoundException (unregistered) in reply to georgir
    georgir:
    The real WTF of course are the parents that could not spell Tabitha properly. (edit: oh wait, it is spelled correctly in the first instance in the article, but not in the rest... )

    Tabitha, Tabatha...

    To-may-to, To-mah-to...

  • Whammy! (unregistered) in reply to Xarthaneon the Unclear

    Totally. No one here has mentioned the fact that we're incredibly lucky to have been born on a planet with 24 hours in each day, I mean it easily could have been 24.7 - praise Jesus!

  • Bill (unregistered) in reply to Remy Porter

    Each of the five small companies I've worked at had home brewed, horrible date and calendar logic just like this article.

Leave a comment on “De-Populate Dates”

Log In or post as a guest

Replying to comment #:

« Return to Article