• sockbot (disco)
    PaulaBean:
    This topic is now unlisted. It will no longer be displayed in any topic lists. The only way to access this topic is via direct link.

    Frist!

    <!-- Posted by SockBot 0.12.5 "Guileful Ginny" on Thu Oct 23 2014 01:37:33 GMT-0400 (EDT)-->
  • VinDuv (disco) in reply to sockbot
    sockbot:
    Frist!
    What took so long?
  • aliceif (disco)
    Comment held for moderation.
  • JBert (disco)
    Comment held for moderation.
  • Medinoc (disco)

    Function is _isSmsCodeExpired()

    Karol replaced most of the function with this: return ((strtotime($genDateStr) + $intervalSec) > time()) ;

    That's TRWTF: The function now returns a Discobool (true when not expired, false when expired).

  • TheIrritainer (disco)

    yup strtotime IS the real wtf, not a very good function to trust when working in a multi locale environment. Always enforce ISO 8106, or just plain Y-m-d H:i:s

  • accalia (disco) in reply to sockbot

    I love seeing my anonymizer in action.....

    I wonder who wanted to post frist but didn't want to do it publically? (resisting urge to log in as sockbot and find out, successfully so far)

  • geoff (disco) in reply to JBert

    No anyone can insert a unix date into the database, the application will take a date string and may or may not generate the result the user was expecting. This nasty UI problem though and always has been. There isn't really a "good" way to differentiate types of date entries other than to validate and reject dates like 30/05/14, but 10/11/14 how can you know? if you were expecting US format. You can try telling the user what to do but they won't read it. You can split the fields out but people don't like entering them separately, you can make them confirm the date after entry but that irritates them, etc.

  • WernerCD (disco)

    Didn't realize the new format changed the tags... silly remmy comments.

  • thegoryone (disco) in reply to JBert
    JBert:
    TRWTF: storing a date as string.

    TRWTF is storing dates/times in string format here. Like JBert said. No developer with a few months (or the common sense to use google/stackexchange) experience does this.

    Smarter solution would be to modify the system passing those strings to pass timestamps instead (Does mktime scare people?) so that you don't need to faff about with strtotime or worry about ISO/European/US formats.

    Edit: Even better, I just had to deal with this on Monday porting data from a legacy system. Fortunately I'm strictly dealing with European date format (And it was server side, not user input fortunately). Solution? Nearly identical. Oh, woe is me. Bonus points for months stored in string format (OCT, DEC, etc).

  • xaade (disco) in reply to geoff

    That's when you use a format string / template.

    The blank template would look like.

    yyyy/mm/dd hh:mm:ss

    Then the user starts to type

    20yy/mm/dd hh:mm:ss

    Put the pattern right where they type and it doesn't obstruct.

  • DCRoss (disco)

    Won't somebody please think of the llamas?

  • xaade (disco)

    After thinking about it, I don't really get the whole increment thing anyway.

    So, you're going to check if the license expired... by adding 2 mins to the license-end date, and seeing if now is greater than that?

    Why 2 mins? In case you started the program seconds before it expired and it takes a while to get to this point?

    ???

    Not to mention this crap.

    intervalSec = 120 {(2 minutes)}.

    explode date into array.

    intervalMin = intervalSec / 60 {(2)}.

    intervalSec = intervalSec - (intervaleMin * 60) {(120 - 60*2, or 0)}

    seconds += 0; minutes += 2; seconds += 0;

    if (seconds > 60) ...

    Seriously? You didn't trust seconds?

  • thegoryone (disco) in reply to xaade
    xaade:
    Seriously? You didn't trust seconds?

    Would you rather fight 60 second sized minutes, or 1 minute sized second?

  • NBeezy (disco) in reply to thegoryone

    I have the pleasure of maintaining several sites where the developers thought it was a good idea to store date/time as a unix timestamp in a VARCHAR(255) (Its better for indexing?). Also they knew that the database couldn't be trusted to generate a unique primary key, so whenever they insert a new record, they make sure to set the id to a call to PHP's time() function (which has the added benefit of NOT WORKING when two records are inserted in the same second, how joyous!)

    And these apps were supposed to be written by people with 10+ years experience in web development.

  • thegoryone (disco) in reply to NBeezy
    NBeezy:
    And these apps were supposed to be written by people with 10+ years experience in web development.

    I think we both know they weren't

  • JBert (disco) in reply to thegoryone

    Actually, that's what they call "having 2 + 2 + 2 + 2 + 2 years experience".

  • Arantor (disco) in reply to aliceif
    Comment held for moderation.
  • Arantor (disco) in reply to thegoryone

    Yes, mktime (or even gmmktime) scares people. The number of people I have dealt with who don't understand WTF a timestamp is surely is TRWTF - but then again to their credit, they're not developers.

  • thegoryone (disco) in reply to Arantor

    I know of one for definite that didn't as of a week ago. I.E. legacy system support I got roped into. I can't quite recall the conversation but the following happened.

    Other dev: What use is that? How would people know the date by looking at that? Me: You format it before you display it... Other dev: That's more work than storing it in readable format to begin with
    And this is the education sector. Is that irony? I can never remember the correct definition. Is *that* irony?
  • Arantor (disco) in reply to thegoryone

    I'm assuming said developer has never heard of the concept of separation of logic and presentation.

    As for it being ironic... it would only be ironic if he were educating people in IT. Right now it's merely another WTF in the room.

    As for the bonus irony... not unless the place you work at was supposed to have taught you what irony was in the first place.

  • boomzilla (disco) in reply to thegoryone
    thegoryone:
    Is that irony?

    Was his shirt wrinkled? Collar unstarched? I fell like I'm not getting something here.

  • Arantor (disco) in reply to boomzilla

    On that note, what about tinny, zincy or maybe alumin[spoiler]i][/spoiler]umy?

  • thegoryone (disco) in reply to Arantor
    Arantor:
    As for it being ironic... it would only be ironic if he were educating people in IT. Right now it's merely another WTF in the room.

    About that...

  • Arantor (disco) in reply to thegoryone
    thegoryone:
    About that...

    Yes?

  • FrostCat (disco) in reply to boomzilla
    boomzilla:
    Was his shirt wrinkled? Collar unstarched? I fell like I'm not getting something here.

    That was an excellent Blakey impression, but I'm going to have to dock points for the lack of gratuituous profanity.

  • boomzilla (disco) in reply to FrostCat

    FUCK YOU<o

  • FrostCat (disco) in reply to boomzilla
    boomzilla:
    FUCK YOU

    I've still got that keyboard with the razor, you--oh, wait.

    Good one.

  • chubertdev (disco)

    What you see:

    (code that gets date from DB)

    What I see:

    // this needs to be completely replaced

  • Yazeran (disco)

    Well I think the whole mess could just have been done in the db (as thay already query the db for the expiredate the way I see it.

    So something along 'SELECT now() > date + INTERVAL '2 minutes' FROM table' (example if using postgresql) should do the trick..... That way they do not have to worry about date format or anything like that....

    Yazeran

    Plan: To go to Mars one day with a hammer.

  • Arantor (disco) in reply to Yazeran

    If it was a timestamp in the database, sure, that would be a thing.

    Would appear they were not that smart. Though I suspect for bonus points they were using a datetime column which would actually have let them do such things right at the SQL layer :laughing:

  • xaade (disco) in reply to thegoryone

    If people engineered the way they code:

    On noes, the engine is still vibrating too much. Quick add more parts until it doesn't.

  • CoyneTheDup (disco) in reply to xaade

    Oh noes, the engine is still vibrating too much, and now excess parts are flying everywhere.

  • chubertdev (disco) in reply to CoyneTheDup
    CoyneTheDup:
    Oh noes, the engine is still vibrating too much, and now excess parts are flying everywhere.

    Now you know which ones weren't necessary!

  • xaade (disco) in reply to chubertdev

    I know, to make sure we account for every configuration of the engine,

    the engine should come with a factory to build engines, and then a factory factory, in case the specifications change so we can dynamically construct factories.

    Then.... I'll never have to work again.

    pffft... maintenance.

  • mott555 (disco) in reply to xaade
    xaade:
    On noes, the engine is still vibrating too much.Quick add more parts until it doesn't.

    The Kerbal Space Program thread is that way :arrow_backward: :arrow_double_down: :arrow_right_hook: :arrows_counterclockwise:

  • kupfernigk (disco) in reply to xaade
    xaade:
    If people engineered the way they code:

    On noes, the engine is still vibrating too much.Quick add more parts until it doesn't.

    Sorry to rain on your parade, but if you compare a modern engine with its double overhead camshafts, balance shafts, torsion dampers, active engine mounts, flexible exhaust downpipe, and bellows in the air intake, to a simple pushrod design with rigid exhaust and bolt-on inlet manifold, you will see that "Add more parts until it doesn't" is exactly what has happened.

  • Martin_Capodici (disco)

    I love how it handles extra seconds (well between 60 and 119) then shuffles back the minutes, hours, days, months and years if they overflow except for the last (add year) overflow that has forgotten to subtract 12 from the months. And also if the month overflows $daysInMonth will probably break. I am not au-fait with PHP but maybe someone can comment. But it looks like 2014-10-01 10:55:77 would be handled but 2014-20-01 10:55:20 would crash?

  • dcon (disco) in reply to boomzilla
    boomzilla:
    Was his shirt wrinkled? Collar unstarched? I fell like I'm not getting something here.

    Did it hurt?

  • brunascle (disco)

    Here's the big surprise, he's actually using strtotime already.

    $daysInMonth = date("t", strtotime($expireDateArr['year'] . "-" . $expireDateArr['month'] . "-01"));
    
  • Yanick (disco)

    Adding seconds without taking care of any DST? Because I didn't see any mention of using UTC in there.

  • Watson (disco) in reply to JBert
    JBert:
    TRWTF: storing a date as string.
    No claim being made here that it is. No indication what DBMS is being used here, but PHP's db client libraries all communicate with the DBMS by sending strings representing SQL queries and when dates come back they're represented by strings formatted according to the db's configuration; the client libraries don't convert those strings into any sort of date object.
  • Bulb (disco) in reply to TheIrritainer
    TheIrritainer:
    yup strtotime IS the real wtf, not a very good function to trust when working in a multi locale environment. Always enforce ISO 8106, or just plain Y-m-d H:i:s

    Having a serious ISO fetish I was also deeply offended by the formats the function uses, but it was the only function I found being able to add time interval of P1M. It had to be expressed as +1M, but at least it was correctly one month.

  • Bulb (disco) in reply to thegoryone
    thegoryone:
    TRWTF is storing dates/times in string format here.

    Unless you are using SQLite where it seems to be the recommended practice as that thing does not have any real types, only integer, real, string and blob (and is manifest-typed).

  • thegoryone (disco) in reply to thegoryone

    He educates people in IT.

  • Arantor (disco) in reply to Watson
    Watson:
    No claim being made here that it is. No indication what DBMS is being used here, but PHP's db client libraries all communicate with the DBMS by sending strings representing SQL queries and when dates come back they're represented by strings formatted according to the db's configuration; the client libraries don't convert those strings into any sort of date object.

    I'm assuming this is MySQL, which has a datetime type - which is accessed as a string and returned as a string even if it is not really a proper string.

  • JBert (disco) in reply to Arantor
    Comment held for moderation.
  • Arantor (disco) in reply to JBert
    Comment held for moderation.
  • Jaloopa (disco) in reply to Arantor
    Arantor:
    what would a datetime column become?

    MSSQL stores datetimes as a numeric representing the number of days since the epoch (01-01-1900 IRC). This allows an unambiguous way of passing them around and converting them

  • Arantor (disco) in reply to Jaloopa

    Ah, MySQL's datetime is not epoch related, meaning you can store pre-epoch dates and times if so inclined. It's also good until Y10k.

    I'd argue that having a string delineating d/m/y h:m:s is as unambiguous as a timestamp. The only question then becomes timezones and that's up to you to figure out anwyay ;)

Leave a comment on “The Beginning of the Zend”

Log In or post as a guest

Replying to comment #:

« Return to Article