Javascript Dates appear to adjust themselves automatically for (US) daylight savings time. Eg
dateInTheDSTPeriod - dateBeforeTheDSTPeriod
will not be a round number of days if both dates represent midnight (because Javascript thinks that by 'midnight' on dateInTheDSTPeriod you mean 0000 BST, 2300 GMT).
Often with astronomy you mean 0000 GMT in the above example, and your date calculations will be an hour off. Get round this by using the ..UTC... versions of all relevant Date methods.
Incidentally, you can add n days to a Date by doing setDate(d.getDate() + n) . I don't know if there's any limit to n but it certainly works up to 366 days.
(Yes, getDate means 'getDayOfMonth', so we are adding n days to the day of month).
NBB A Date is an object: if you assign d2=d1, d2 is the same object as d1, and if d1's properties change, so will d2's, and vice versa. Bit annoyed with myself for not realising that tbh.
The way to shallow copy is d2 = new Date( d1.valueOf() ) .
Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.
Quick
- ($a, $b....) = unpack("A2A7...", $packed)
- push( array, list )