Description
This issue was originally filed by @seaneagan
Many date libraries provide constructors with optional arguments for each date part beyond the year, each defaulting to the smallest possible amount. In Dart this could look like:
Date(
int year, [
int month = 1,
int day = 1,
int hour = 0,
int minute = 0,
int second = 0,
int millisecond = 0,
this.timeZone = TimeZone.LOCAL]); // see issue #2581
This also removes the need for Date.withTimeZone
Examples:
Date now = new Date.now();
Date startOfDay = new Date(now.year, now.month, now.day);
Date eightOClock = new Date(now.year, now.month, now.day, 8);
Date endOfDay = new Date(now.year, now.month, now.day + 1);
Date startOfMonth = new Date(now.year, now.month);
Date ides = new Date(now.year, now.month, 15);
Date endOfMonth = new Date(now.year, now.month + 1);
Date startOfYear = new Date(now.year);
Date middleOfYear = new Date(now.year, Date.JUL);
Date endOfYear = new Date(now.year + 1);
See:
only year required:
http://www.ruby-doc.org/core-1.9.3/Time.html
http://momentjs.com/docs/#/parsing/javascript-array/
year, month, and day required (less useful):
http://docs.python.org/library/datetime.html#datetime-objects
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date
Activity
kasperl commentedon Apr 17, 2012
Added Area-Library, Triaged labels.
floitschG commentedon May 14, 2012
Issue #1422 has been merged into this issue.
floitschG commentedon Jun 20, 2012
Fixed some weeks ago.
Added Fixed label.
Bump pub version