You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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);
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
The text was updated successfully, but these errors were encountered: