5

To me it looks fine, other than it makes me scroll the code to read it. On this ground I agree with Sam, that line ought to be shortened. To do so I would use the fact that you don't need to convert mysql format dates to compare them remove excessive bracing use De Morgan's law to invert the condition and get this function dates_in_range( string $...


5

public LocalDateTime parseDate(String dateString) { Your formatting choices are partly odd, if in doubt, stick to the IDE default formatting (or the formatting of the project. checkArgument(!Strings.isNullOrEmpty(dateString), "Date [" + dateString + "] is empty of NULL!"); Split it into two checks, one for null and one for empty, ...


4

"A mess" is the first thing that comes to my mind. Why don't you just use a loop over the various formats? If you want to introduce a special guard (like the string length), create a parser objcet, which implements an appropriate check. Something along the lines of interface DateParser { boolean isApplicable(String in); LocalDateTime parse(...


4

The function seems okay. In Javascript one could use the method Array.every(), but as this StackOverflow question illustrates there isn't really an equivalent method or functional approach in PHP that will stop the loop as soon as one element does not meet the requirement. You might consider adhering to the PSR PHP Coding standards - especially PSR 12. PSR-...


1

in_day = [weekday for weekday in weekdays if word in weekday] if len(in_day) == 1: seems odd. You make the entire list, put it in memory, take its length and then throw it away. Consider instead n_matching = sum(1 for weekday in weekdays if word in weekday) if n_matching == 1: This loop: for word in words: in_day = [weekday for weekday in weekdays ...


Only top voted, non community-wiki answers of a minimum length are eligible