Most of the exported variables that affected how parsing and formatting is
done are now combined into a single DEFAULT_CONFIG
object. Both strftime()
and strftime()
now take the third argument, config
, which defaults to this
object, and contains many of the configuraiton elements.
The DAY_MS
variable is no longer exported and, thus, no longer configurable.
Now in addition to resetTime()
there is also resetWeek()
which resets the
week of a date (rewinds it to the start of the week), including support for
custom configuration of the week start day.
These functions were removed as they are trivial to write yourself. Here are some examples (although not 100% replicating the old behavior):
import datetimejs from 'datetimejs'
const {resetTime, resetWeek} = datetimejs.datetime;
function today() {
return resetTime(new Date());
}
function thisMonth() {
let d = new Date();
d.setDate(1);
return d;
}
function thisWeek() {
return resetWeek(new Date());
}
The functions like isAfter()
, isBefore()
and similar have all been removed
except isLeapYear()
. These are trivially replicated using normal comparison
operators.
For example, isAfter(myDate, refDate)
is just myDate > refDate
.
A function has been added to dtdate
object, createDelta()
, which allows
creation of delta objects by specifying the relative difference in
milliseconds, instead of using two Date
objects.
A companion addDelta
function has been added to datetime
object, which can
be used to add a delta object to a Date object.
This token is commonly used to represent the literal percent character.
The strftime()
function would previously try all format tokens regardless of
which ones are actually used in the format string. This is now changed so that
only those that are actually present will be considered. This should result in
a minor perofrmance improvement.
Instead of running tests in a HTML file, Jest is now used, allowing CI integration.
Package management has been switched to Yarn.
The final production build contains CommonJS, ES6 module, and UMD module, compiled using Rollup.
Previously, date would default to 0, which caused the parsed Date
oject to
always be one day behind than expected.
The Volo support was dropped, and CoffeeScript sources were cleaned up from the source tree. The next release will clean up the remaining JavaScript files.
It was broken when hour is 12. Now all fixes.
The timeAdjust
parameter generated by %p
was not being used.
This method reformats string date/time from input format to output format.
The variables are now all accessed through the datetime
object, so it is
possible to override any and all variables at runtime.
This release is not backwards compatible.
They are now in datetime.dtdelta
submodule.
New parse
and format
submodules are now available. strptime
, strftime
,
isoparse
and isoformat
are now aliases for methods in those submodules.
New tests were added and bugs squatted.
DAY_MS
, REGEXP_CHARS
, and PARSE_TOKEN_RE
are now exposed, although some
of them are not overridable.
They had the opposite results. This has now been fixed, and it's a backwards-incompatible change.
The way Date objects were cloned by passing them to Date constructor was
clearly not a very bright idea. It seems that on most browsers this causes the
data object to be evaluated to a string or something similar, thus loosing the
millisecond bit. While this was fine in some cases, it wasn't fine for the
#delta()
method.
Apart from many bugfixes and additonal unit tests...
The zeroPad now takes one extra argument tail
, which allows padding from the
tail end of float numbers.
Format and parse date and time using ISO format '%Y-%m-%dT%H:%M:%f'
This token will return seconds with a fractional part, zero-padded and two tail-padded float digits.