|
|
|
|
|
by henrikschroder
3809 days ago
|
|
You can't perform the operations "add one month" or "add one year" if you're working with seconds since the epoch. For storing a timestamp, absolutely, you should use an integer-based format, counting discrete somethings since somewhen. For working with timestamps, you need all the nuance, you need something that can manipulate the different parts of it independent of each other. And finally, for displaying or reading timestamps, you need all the localization and parsing crap to figure out what "020304" means. Fourth of March 2002? Third of February 2004? |
|
Adding 1 month or 1 year to the current date is usually a mistake. Quick question, what do you expect to happen when you code "Jan 31 + 1m"? What do you expect to happen when you code "Feb 29 2016 + 1y"? If you are thinking about doing this, ask yourself if it wouldn't make more sense to define your time by days instead. Jan 31 + 30 days, or Feb 29 + 365.25 days. Of course days are easy to implement on epoch time as well ( time + 30 * SECONDS_PER_DAY ).