6 kyu

Pretty date

104 of 885burce
Description
Loading description...
Date Time
Fundamentals
  • Please sign in or sign up to leave a comment.
  • goldenratio161 Avatar

    the title attracted me

  • trashy_incel Avatar

    fork adding sample and random tests to JS, + upgrading to Node 18 and chai assertions

    (author is gone)

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • blzzua Avatar

    Author's python solution assume that arguments from diapason 84600 - 86399 (23 hours 30 minutes 00 seconds - 23 hours 59 minutes 59 seconds) must to return '0 days ago'

  • trashy_incel Avatar

    Write a helper function that takes in a Time object and converts it to a more human-readable format

    In JavaScript / Python, we are given a plain Number / int though, not an object

  • trashy_incel Avatar

    no sample tests in JavaScript

  • suic Avatar

    I've got this in Python random tests:

    Testing for 84968 seconds in the past It should work for random inputs too: '23 hours ago' should equal '0 days ago'

    IMO it's not correct.

    Regards,

    suic

  • Calculating Nut Avatar

    issue:

    There is some internal array named "times" which is initialized between the preset tests and the randomized tests. It was conflicting with my own list named 'times', causing my code to appear to magically stop working partway through testing. It would be nice if there was a warning or something not to use that name, as this issue caused me to waste plenty of my time with pointless debugging.

  • MMMAAANNN Avatar

    This comment has been hidden.

  • GiacomoSorbi Avatar

    Python translation submitted :)

    I would add random cases to each language and can do it if you wish, but you of course have the last word :)

    Edit: oh, and kata green-lit.

  • ZozoFouchtra Avatar

    JS translation kumited. (Description modified)

  • mlabrum Avatar

    Major Issues

    The description is not sufficiently detailed. Based on assumptions derived while trying to pass this kata, I believe the following details need to be added:

    • The output will be an amount of time, t, included in one of the following phrases: "just now", "[t] seconds ago", "[t] minutes ago", "[t] hours ago", "[t] days ago", "[t] weeks ago".
    • You will have to handle the singular cases. That is, when t = 1, the phrasing will be one of "a second ago", "a minute ago", "an hour ago", "a day ago", "a week ago".
    • The amount of time is always rounded down to the nearest integer. For example, if the amount of time is actually 11.73 hours ago, the return value will be "11 hours ago".
    • Only times in the past will be given, with the range "just now" to "52 weeks ago"

    Minor Issues

    The formatting in the description can be cleaned up a little, e.g.,

    to_pretty(Time.now - 40000) # => "11 hours ago"
    

    (see Description Markdown Field for the markdown; I can't figure out the markdown for showing markdown)

    Optional Additions

    Times in the future, with the suffix "from now" instead of "ago" would be an interesting addition and isn't too much more difficult to deal with.

    I'm a fan of random test cases, so I'll also recommend adding a few of them.

  • Abbe Avatar

    It's a nice kata. And my solution was unneccesary complicated. :-)

    Did you consider adding times in the future as well? Like "in 3 hours" or so?