Skip to content
This repository has been archived by the owner on Jul 31, 2020. It is now read-only.

Commit

Permalink
--------------------
Browse files Browse the repository at this point in the history
2008-05-12 [geoffrey.mcgill]
Revision #191

1.  Added .same() function to sugarpak.js. The new .same() function will compare two date objects to 
	determine if they occur on/in exactly the same instance of the given date part.
	
	The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc).
	
	An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used. 
	
	Scenario: Determine if two dates fall on the exact same day.
    
    Example
    
    var d1 = Date.today(); // today at 00:00
    var d2 = new Date();   // exactly now.

    // Do they occur on the same day?
    d1.same().day(d2); // true
    
     // Do they occur on the same hour?
    d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).
    
    // What if it's the same day, but one year apart?
    var nextYear = Date.today().add(1).year();

    d1.same().day(nextYear); // false, because the dates must occur on the exact same day. 
    
    
    Scenario: Determine if a given date occurs during some week period 2 months from now. 
     
    Example
    
    var future = Date.today().add(2).months();
    return someDate.same().week(future); // true|false;
    
2.  Added Date.prototype.toObject() function to sugarpak.js. The .toObject will return an object literal of all the date parts.
	
	Example
	
	var o = new Date().toObject();
	
	// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }
	
	The object properties can be referenced directly from the object.
	
	alert(o.day);  // alerts "13"
	alert(o.year); // alerts "2008"

3.  Added Date.fromObject(config) to sugarpak.js. The .fromObject will return a new Date based on the config properties.

	Example
	
	var o = someDate.toObject();
	return Date.fromObject(o); // will return the same date as "someDate"

    var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
    Date.fromObject(o2);
    
--------------------
  • Loading branch information
geoff@coolite.com committed May 14, 2008
1 parent 18d7f5e commit 4b8868c
Show file tree
Hide file tree
Showing 324 changed files with 3,424 additions and 1,769 deletions.
74 changes: 69 additions & 5 deletions CHANGELOG.txt
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,67 @@
CHANGE LOG CHANGE LOG
-------------------- --------------------

2008-05-12 [geoffrey.mcgill]
Revision #191

1. Added .same() function to sugarpak.js. The new .same() function will compare two date objects to
determine if they occur on/in exactly the same instance of the given date part.

The function .same() must be followed by a date part function (example: .day(), .month(), .year(), etc).

An optional Date can be passed in the date part function. If now date is passed as a parameter, 'Now' is used.

Scenario: Determine if two dates fall on the exact same day.

Example

var d1 = Date.today(); // today at 00:00
var d2 = new Date(); // exactly now.

// Do they occur on the same day?
d1.same().day(d2); // true

// Do they occur on the same hour?
d1.same().hour(d2); // false, unless d2 hour is '00' (midnight).

// What if it's the same day, but one year apart?
var nextYear = Date.today().add(1).year();

d1.same().day(nextYear); // false, because the dates must occur on the exact same day.


Scenario: Determine if a given date occurs during some week period 2 months from now.

Example

var future = Date.today().add(2).months();
return someDate.same().week(future); // true|false;

2. Added Date.prototype.toObject() function to sugarpak.js. The .toObject will return an object literal of all the date parts.

Example

var o = new Date().toObject();

// { year: 2008, month: 4, week: 20, day: 13, hour: 18, minute: 9, second: 32, millisecond: 812 }

The object properties can be referenced directly from the object.

alert(o.day); // alerts "13"
alert(o.year); // alerts "2008"

3. Added Date.fromObject(config) to sugarpak.js. The .fromObject will return a new Date based on the config properties.

Example

var o = someDate.toObject();
return Date.fromObject(o); // will return the same date as "someDate"

var o2 = {month: 1, day: 20, hour: 18}; // birthday party!
Date.fromObject(o2);

--------------------

2008-05-12 [geoffrey.mcgill] 2008-05-12 [geoffrey.mcgill]
Revision #190 Revision #190


Expand All @@ -14,20 +76,22 @@ Revision #190
Date.today().add(-1).day().is().today(); // false Date.today().add(-1).day().is().today(); // false


-------------------- --------------------

2008-05-07 [geoffrey.mcgill] 2008-05-07 [geoffrey.mcgill]
Revision #182 Revision #189


1. Fixed bug in TimePeriod. See http://code.google.com/p/datejs/issues/detail?id=39 1. Fixed bug in TimePeriod. See http://code.google.com/p/datejs/issues/detail?id=39


Example Example


var start = new Date(); var start = new Date();
var end = Date.today().add(15).days(); var end = Date.today().add(15).days();
var ts = new TimePeriod(start, end); var ts = new TimePeriod(start, end);


ts.getDays(); // 14 ts.getDays(); // 14


-------------------- --------------------

2008-04-25 [geoffrey.mcgill] 2008-04-25 [geoffrey.mcgill]
Revision #182 Revision #182


Expand Down
8 changes: 4 additions & 4 deletions build/core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4b8868c

Please sign in to comment.