Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix endOf day on brazilian DST start being the next day #4804

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/moment/start-end-of.js
Expand Up @@ -55,5 +55,5 @@ export function endOf (units) {
units = 'day';
}

return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
return this.add(1, (units === 'isoWeek' ? 'week' : units)).startOf(units).subtract(1, 'ms');
}
21 changes: 21 additions & 0 deletions src/test/moment/start_end_of.js
Expand Up @@ -347,6 +347,27 @@ test('startOf across DST +1', function (assert) {
moment.updateOffset = oldUpdateOffset;
});

test('endOf across DST +1', function (assert) {
var oldUpdateOffset = moment.updateOffset,
// Based on a real story somewhere in America/Sao_Paulo
dstAt = moment('2018-11-04T00:00:00-03:00').parseZone(),
m;

moment.updateOffset = function (mom, keepTime) {
if (mom.isBefore(dstAt)) {
mom.utcOffset(-3, keepTime);
} else {
mom.utcOffset(-2, keepTime);
}
};

m = moment('2018-11-04T09:00:00-02:00').parseZone();
m.endOf('d');
assert.equal(m.format(), '2018-11-04T23:59:59-02:00', 'endOf(\'d\') across +1');

moment.updateOffset = oldUpdateOffset;
});

test('startOf across DST -1', function (assert) {
var oldUpdateOffset = moment.updateOffset,
// Based on a real story somewhere in America/Los_Angeles
Expand Down