6 kyu
Count the days!
757 of 2,167zruF
Loading description...
Date Time
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Nice one, well done.
This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/192.
Please join the discussion to help us identify duplicate kata and retire them.
thank you, I added a comment.
test writes: Wrong number of days for December 31, 2511 Expected: 178711 days
i write console.log() and it writes 178711
i cant understand what's wrong?
That ^
And that ^
i've missed space :) thank you
This comment has been hidden.
Kata suggests that "You have to round the amount of days."
thank you, haven't noticed that!
.
This comment has been hidden.
Very valid point; thanks for your feedback. I have updated the tests to generate dates much closer to the 'present', your solution has been invalidated ;-)
let me know if there are further problems
This comment has been hidden.
Should this kind of solution be valid? https://www.codewars.com/kata/reviews/584e740a076cc35402000623/groups/6315ef99dc2cd20001196a67
Some test cases will give you an error. You have to find out how to round days
In that case, that kind of solution should not be passable. Kata's tests are weak.
If you don`t have much practise in codes with date and time - this kata is for you. Thank you for helping me in my study
C translation ⏲🗓
Approved ny author secretly
This comment has been hidden.
This comment has been hidden.
I stumbled over the same behavior in Java. It's caused by the rounding behavior where the 23:59:59.99948S time difference is considered as 0 days. It seems like an issue as the kata author passes Long value to Math.round() that is useless.
Funny Kata, get me to play with almost everything about Date&Time in Java, thx!
This comment has been hidden.
A little typo in the description:
She want[S] to know how many days she ha[S] to wait for a specific event.
fixed by someone
I have the result like "4096 days expected but got 4096.00.00.00 days" Make it be insensetive for this.
This comment has been hidden.
Which language? ;)
In the Java version.
Fixed!
This comment has been hidden.
Thanks for your contribution! That's the reason why I wrote in the description that the amount of days should be rounded ;-) So if it's less than 12 hours, it's the same day ;)
Solved this kata, but it fails when running sample tests (missing ")" ). Posted as attempt, and it passed all tests, submited and all is OK. So I think there is some problem with sample tests.
Please verify. Many thanks
CoffeeScript translation kumited! Please accept :smile:
Accepted! Thanks for your translation :)
Thank you!
This comment has been hidden.
This is the wrong kata, dude.
This comment has been hidden.
I wrote "The function will take a Date object as parameter. " in the description. Here you can learn more about Date Objects.
My bad about the date object, i didn't read the instructions enough. I didn't know that was an actual date object, i thought you were just making it for this kata.
And sorry for posting a question from another kata on this one by mistake. I have no idea how that happened.
Using the old deprecated Date constructor is bad practice and the test cases need a revamp.
seems more like 7yu, but i like it! so many different solutions =)
Just pointing out that the constructor "New Date(2000-1900,12,24)" in Java is deprecated for a reason. It creates a whole different level of complexity that I think is unnecessary. The "12" (which i assume you mean "December") is automatically seen as "0"(which is "January"). Which basically means that you can not figure out which month to use when calculating the days without either changing the parameters(which I cant) or applying a ton of different formaters (if even possible). Or am I totally wrong about this?
Fixed it ;)
I added example tests in every language. Fixed expected - actual in C#
Wow! I like this kata!
Ashamed to admit it, but I spent almost 2 days (at least 20 hours) trying to solve this kata. And finally I found the solution.
But when I saw another solutions, I realized that I solved this kata in the most horrible possible way.
Very good lesson for me. Thanks for kata!
No shame! Part of the growing process. How is your progress as a coder going sir?
The third test says the output should be 'The day is in the past!' but the input date matches today's date (as of this writing). Since the instructions say to round the date, I strip off the date before comparing. Whatever is generating the tests may be including the time .
I just started on codewars a few weeks ago so maybe I'm missing something but I have a failing test on this kata that roughly says :
" expected was "0 days" and actual was "Today is the day!" "
so I think there is a little problem with this test..
Unfortunately expected and actual are the wrong way around. so your output is "0 days" ;)
Managed to fix it ;)
This kata does not account for leap years?
Leap years are handled by the Date objects automatically, e.g. you can get the date of 29.02 of 2016.
C#: "Expected" and "But was" are the wrong way around.
Also, initial test cases are missing.
Missing test cases for Javascript as well
Unfortunately, I can't change the tests, so I can't fix that, but i think this isn't an issue. You can solve this kata anyway ;)
I added some example tests in every language!
I fixed that! ;)
Hi, in some case test I'm getting a day more than expected, I supposed that a need to run my Attempt y an especific time. I'll try tomorrow again
You have to take hours, minutes and seconds into account too. Moreover you have to round your output
These tests don't do a good job of checking for off-by-one errors. I see a lot of
Math.round
solutions and those are going to produce off-by-one errors depending on whether theDate
is at the start or end of the day (and when the test is run).In which language? For Python, tests use
date.now()
and take hours, minutes and seconds into account too. Don't forget you have to round your output as said in description.This comment has been hidden.
Fun kata, but I have one question with it. I got all tests to pass but one, which says that January 8, 2017 should output today is the day! But today is January 7, 2017. Does the function have to check a 24hr timeframe or something?
Oops, relatively new here. I probably should have posted in issues but didn't see it.
Where do you come from? The time of the codewars server might be a little bit different than yours.
This kata wants to be approved :)
Done ;-)
Thank you ;)
This comment has been hidden.
This comment has been hidden.
Finally got it!
Nice kata, I've learned a lot with it.
Python translation as no preloaded template.
Whoops, sorry. Should be fixed now!
This comment has been hidden.
I also added the Java and C# translation.
It would be good to add random tests, to make sure noone cheats...
Good point! I added some ;)
Nice! Now you wont have any issues about random tests :)
I've completed this kata and it passes lots of my tests, and all of your tests but the first one. You really have to be more descriptive in your kata as there is a lot of amibiguity
Thanks for your contribution! I added some more testcases with input and expected output.
So the issue can be closed now.