Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Not strictly the cycle of the moon but close.

Meh. Just the old 49.7 days cycle that it takes to overflow 32 bits when measuring miliseconds.

I was hoping for a "it works when I buy vanilla icecream and doesn't when I buy other flavour".



I was also hoping the title was more accurate. In the lines of the famous story of not being able to send an email 500 miles.

https://web.mit.edu/jemorris/humor/500-miles


The end of that article is a good reminder of the units command, I've been using Google for units conversion for so long that I forgot about the standalone units. It even comes standard with OSX.


I love the GNU units program so much. I think I use it at least 4 times/week. It's useful for kitchen conversions and also quick nuclear fuel burnup calcs. For example I used it on this blog post covering the long-term sustainability of nuclear fuel resources on earth.

https://whatisnuclear.com/blog/2020-10-28-nuclear-energy-is-...


> It's useful for kitchen conversions and also quick nuclear fuel burnup calcs.

Also electrical engineering and estimates of the feasibility of brute-forcing cryptographic primitives using the mass of the observable universe as fuel.


Interesting kitchen you have. Calculating nuclear fuel burnup.

I wonder what's cooking? Does it glow in the dark? ;>


> I wonder what's cooking?

Yellow cake.


Is there an equivalent command for doing things like 147 days from today or days since 21 jun 2021 or 88 days after 15 Aug 2021? This is the one thing I really wish was in Spotlight (I use spotlight for unit conversion and calculations which is really handy).


WolframAlpha works well for those types of calculations.


With GNU date (but not the BSD-based macOS date, I believe), and not all that convenient for "days since":

  $ date -d 'today + 147 days' +%F
  2022-02-23
  
  $ echo $(( ($(date +%s) - $(date -d '2021-06-21' +%s)) / 86400 ))
  100
  
  $ date -d '2021-08-15 + 88 days' +%F
  2021-11-11



To clarify, I was thinking a quick command line thing. Right now, I do it in a browser (both DuckDuckGo and Google produce the answer easily enough).


The unix date command does this.


Well, GNU date does, BSD date may or may not.

Linux box:

  $ date -d 'now + 4711 days ago'
  Thu Nov  6 06:57:20 UTC 2008
  $ date --version
  date (GNU coreutils) 8.30
  Copyright (C) 2018 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later 
  <https://gnu.org/licenses/gpl.html>.
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.

  Written by David MacKenzie.
Mac:

  % date -d 'now + 4711 days ago'
  usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... 
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
I also seem to be unable to pull a version out of the Mac's date command.


I use the Python datetime module for stuff like that. Excel can be useful too, since it treats dates as a number of days.


I always thought the problem was obvious by the title. And felt good about myself for a long time after I read it. Now that I am well into adulthood knowing does not seem that amazing.


Thanks for sharing, this is a great read!


Yes and:

> Just the old 49.7 days cycle...

I've encountered datetime bugs and learned to take preventative measures.

I generally add a virtual clock shim to my projects, eg wrapping System.currentTimeMillis() or equiv.

Then I write unit tests for anticipated edge cases. Like midnight, end/start of year, etc. To ensure reporting, rollups, logging, grooming, etc. are working correctly.

Also allows me simulate elapsed time, so I verify out of order event processing and so forth.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: