Skip to main content

All Questions

7 votes
2 answers
281 views

Subtract two lap times (m:ss:fff)

I have two lap time strings I need to subtract, the format is minutes, seconds, milliseconds. This is to compare a new world record time to the previous holder's ...
Soda Party's user avatar
0 votes
1 answer
3k views

Formatting milliseconds as days, hours, minutes, and seconds [closed]

This is a function which aims to convert an amount of milliseconds to a more human-interpretable Day(s) Hour(s) Minute(s) Second(s) format: ...
user avatar
4 votes
5 answers
163 views

Leap year determination using guard clause

I have a function to check the leap year as follows ...
azemda's user avatar
  • 41
7 votes
4 answers
31k views

Sorting dates in this format (DD-MM-YYYY)

Is this the correct and an elegant way to sort the dates in the format (DD-MM-YYYY) in ascending order? ...
Mark Adel's user avatar
  • 317
3 votes
1 answer
2k views

Generate next available filename based on current date

I have a bit of code that I would like your collective opinions on. Currently, my working code has two return statements. I'm not sure how I feel about having multiple points of exit, however, the ...
Jaken's user avatar
  • 177
4 votes
3 answers
2k views

Leap year check in Haskell, using pattern matching or bind operator

One of the first Haskell puzzles on http://exercism.io/ is to implement a leap year check. I've done this twice. Using pattern matching: ...
Matthias Wimmer's user avatar
1 vote
1 answer
150 views

Sort by year and day descending, yet time ascending

I recently discovered a hugely inefficient portion of code in my program, and have gone about rewriting it. I am however, not quite sure if the rewritten program actually does exactly what I want, due ...
Daniël van den Berg's user avatar
11 votes
4 answers
548 views

Function to format the local time

This is a statement that I use a lot in my code base: (LocalDateTime.now()).format(DateTimeFormatter.ofPattern("ssmmHHddMMMuu")) Should I create a static method ...
RajKon's user avatar
  • 229
1 vote
1 answer
37 views

Finding the year using strtotime vs calculating manually

I need to calculate at which year a school class has started, given the year they currently are in. For example a class of 2nd graders have started school in 2013, if I pass 2 to the function it ...
php_nub_qq's user avatar
1 vote
1 answer
3k views

Handling overwriting of unique Dictionary values

I am working in C# to write a scheduling application for operations in a factory. I have a custom class Workday, with properties to represent a ...
PugsOverDrugs's user avatar
4 votes
1 answer
2k views

Fast regex to extract strings before and after a time

I want to get text1 and text2 by splitting time format Text1 10:24:02 Text2 Of the two ...
Fast Snail's user avatar
3 votes
3 answers
1k views

Parsing and formatting a time two ways (perfectionistic approach)

I'm still not satisfied by the readability of the code. The wanted behavior which would be self descriptive would sound like: "I've two fields; one is for the date and one for the hour. This two ...
Revious's user avatar
  • 503
1 vote
2 answers
338 views

Translating month number into month name

Time is very important from times immemorial. Doing great things and making it happen in less time is more important as it can mean less effort. So I really like to know which way is faster and more ...
Mawia HL's user avatar
  • 285
7 votes
3 answers
266 views

Enumerating new articles whose publication start date has passed

(cn.PublishEnd == null || cn.PublishEnd < DateTime.Now) vs (cn.PublishEnd ?? DateTime.MinValue < DateTime.Now) Which ...
bevacqua's user avatar
  • 357
3 votes
2 answers
365 views

Two code snippets involving time-change

I have two snippets that are going to be used in a walkthrough and I'd like some feedback on which one is more easily understandable 1 ...
Arnab Datta's user avatar

15 30 50 per page