Skip to content

Latest commit

 

History

History
179 lines (109 loc) · 4.95 KB

CHANGES.md

File metadata and controls

179 lines (109 loc) · 4.95 KB

DatetimeJS changelog

1.0.0

Changes in configuration

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.

DAY_MS is no longer exported

The DAY_MS variable is no longer exported and, thus, no longer configurable.

Added resetWeek()

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.

Removed today(), thisWeek(), and thisMonth()

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());
}

Removed all comparsion functions from dtdelta

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.

Addition of createDelta() and addDelta()

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.

Addition of %% format and prase token

This token is commonly used to represent the literal percent character.

strftime() performance optimization

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.

Switch from Mocha/Chai to Jest

Instead of running tests in a HTML file, Jest is now used, allowing CI integration.

Switch to Yarn

Package management has been switched to Yarn.

Variety of builds

The final production build contains CommonJS, ES6 module, and UMD module, compiled using Rollup.

0.3.5

Fixed parsing with no date specified

Previously, date would default to 0, which caused the parsed Date oject to always be one day behind than expected.

Removed Volo support and CoffeeScript sources

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.

0.3.4

Fixed hour24 utility

It was broken when hour is 12. Now all fixes.

0.3.3

Fixed parsing of the %p token

The timeAdjust parameter generated by %p was not being used.

0.3.2

Added datetime.format.reformat() method

This method reformats string date/time from input format to output format.

0.3.1

Changed the way varaibles are read internally

The variables are now all accessed through the datetime object, so it is possible to override any and all variables at runtime.

0.3.0

This release is not backwards compatible.

The #delta() and time/date-difference-related methods are moved

They are now in datetime.dtdelta submodule.

parse and format submodules

New parse and format submodules are now available. strptime, strftime, isoparse and isoformat are now aliases for methods in those submodules.

Test suite nearing completion

New tests were added and bugs squatted.

New variables exposed

DAY_MS, REGEXP_CHARS, and PARSE_TOKEN_RE are now exposed, although some of them are not overridable.

0.2.0

Fixed previously broken isBefore and isAfter

They had the opposite results. This has now been fixed, and it's a backwards-incompatible change.

Fixed failing tests on IE and FireFox

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.

0.1.0

Apart from many bugfixes and additonal unit tests...

zeroPad API change

The zeroPad now takes one extra argument tail, which allows padding from the tail end of float numbers.

datetime.isoformat and datetime.isoparse

Format and parse date and time using ISO format '%Y-%m-%dT%H:%M:%f'

Addition of %f formatting and parsing token

This token will return seconds with a fractional part, zero-padded and two tail-padded float digits.