4 ms·
I'm being a little facetious here because the fact Copilot can generate something that I can complain about is truly amazing, but the suggested code for the 'ca
by onion2k 5y ago
I'm being a little facetious here because the fact Copilot can generate something that I can complain about is truly amazing, but the suggested code for the 'calculate days between two dates' example is really horrible. It's going to go quite wrong any time the two dates cross a Daylight Savings Time boundary, or if the Date objects are using two different timezones, or if either date isn't a Date, etc.
function calculateDaysBetweenDates(date1, date2) {
var oneDay = 24 * 60 * 60 * 1000;
var date1InMillis = date1.getTime();
var date2InMillis = date2.getTime();
var days = Math.round(Math.abs(date2InMillis - date1InMillis) / oneDay);
return days;
}
It's definitely as good as the code I was writing for the first few years of my career though, and I can see that it could improve significantly with more data. I'm absolutely looking forward to seeing where it goes.
- sktrdie 5y agoPoint is that the average does in fact write code worst than that (including myself). Having this kind of stuff automated in such a way that it is somewhat "looked after by GitHub" will increase the quality of software overall.