Skip to main content
added 345 characters in body
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158

This trivial code snippet appears to achieve some of its design goals, though there are some aspects worth discussing.

ShipThe YDM vs YMD formatting convention needs to be worked out prior to deploying in production. At a minimum we need a comment explaining the situation (preferably a test which throws fatal error if it sees unexpected default date format), plus adequate unit tests. The "break out an IN_RANGE() helper" item would fit in perfectly with unit tests.

This trivial code snippet appears to achieve its design goals, though there are some aspects worth discussing.

Ship it.

This trivial code snippet appears to achieve some of its design goals, though there are aspects worth discussing.

The YDM vs YMD formatting convention needs to be worked out prior to deploying in production. At a minimum we need a comment explaining the situation (preferably a test which throws fatal error if it sees unexpected default date format), plus adequate unit tests. The "break out an IN_RANGE() helper" item would fit in perfectly with unit tests.

edited body
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158

This ismakes the meaning more visually apparent, as it's a closer approximation to how a math text or python engineer would typically chain it, and makes the meaning more visually apparent:

This is a closer approximation to how a math text or python engineer would typically chain it, and makes the meaning more visually apparent:

This makes the meaning more visually apparent, as it's a closer approximation to how a math text or python engineer would typically chain it:

added 166 characters in body
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158

I recommend expunging YDM format from this (or any other) codebase. If an instant in time is represented as text, stick to the convention of representing it in ISO-8601 form. It is unambiguous, readily parsed, and has a useful collation order. Remember that a DateYMD < DateYDM character comparison is not meaningful, so it can't produce the correct result. https://imgs.xkcd.com/comics/iso_8601.png

Unit testing can help to reveal difficulties like format mismatches.

I recommend expunging YDM format from this (or any other) codebase. If an instant in time is represented as text, stick to the convention of representing it in ISO-8601 form. It is unambiguous, readily parsed, and has a useful collation order. https://imgs.xkcd.com/comics/iso_8601.png

I recommend expunging YDM format from this (or any other) codebase. If an instant in time is represented as text, stick to the convention of representing it in ISO-8601 form. It is unambiguous, readily parsed, and has a useful collation order. Remember that a DateYMD < DateYDM character comparison is not meaningful, so it can't produce the correct result. https://imgs.xkcd.com/comics/iso_8601.png

Unit testing can help to reveal difficulties like format mismatches.

added 8 characters in body
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158
Loading
added 206 characters in body
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158
Loading
Source Link
J_H
  • 43.3k
  • 3
  • 38
  • 158
Loading