arshaw / xdate

A Modern JavaScript Date Library
http://arshaw.com/xdate/
GNU General Public License v2.0
681 stars 81 forks source link

Tomorrow and yesterday methods #20

Closed DeTeam closed 11 years ago

DeTeam commented 11 years ago

It may be handy to have those two methods for XDate object.

xdate.tomorrow() xdate.yesterday()

That'd just move the date (not time) to the next or prev. date. What do you think?

daniel-white commented 11 years ago

what's wrong with .addDays(-1) and .addDays(+1)?

DeTeam commented 11 years ago

Does it mute prev. date?(:

On Monday, March 4, 2013, Daniel A. White wrote:

what's wrong with .addDays(-1) and .addDays(+1)?

— Reply to this email directly or view it on GitHubhttps://github.com/arshaw/xdate/issues/20#issuecomment-14384536 .

Best Timur DeTeam Amirov Moscow, Russia

daniel-white commented 11 years ago

@DeTeam what do you mean by "mute"?

DeTeam commented 11 years ago

"Mutable state" like that It modify existing date object or create new one? Those methods I proposed wouldn't touch existing date and create new one

On Monday, March 4, 2013, Daniel A. White wrote:

@DeTeam https://github.com/DeTeam what do you mean by "mute"?

— Reply to this email directly or view it on GitHubhttps://github.com/arshaw/xdate/issues/20#issuecomment-14384748 .

Best Timur DeTeam Amirov Moscow, Russia

daniel-white commented 11 years ago

it mutates the internal state.

You can easily then just .clone().addDays(-1) and .clone().addDays(+1)

DeTeam commented 11 years ago

Ok, it'd just be semantically handy to have shortcuts for that :)

On Monday, March 4, 2013, Daniel A. White wrote:

it mutates the internal state.

You can easily then just .clone().addDays(-1) and .clone().addDays(+1)

— Reply to this email directly or view it on GitHubhttps://github.com/arshaw/xdate/issues/20#issuecomment-14387298 .

Best Timur DeTeam Amirov Moscow, Russia

arshaw commented 11 years ago

you could extend XDate...

XDate.prototype.tomorrow = function() {
    return this.clone().addDays(1);
};