Mercurial > projects > dwt-linux
diff dwt/widgets/DateTime.d @ 308:dc2ae028d2d8
Fix: DateTime to startup with current Date/Time.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 22 Aug 2008 21:36:05 +0200 |
parents | c0d810de7093 |
children |
line wrap: on
line diff
--- a/dwt/widgets/DateTime.d Thu Aug 21 17:34:04 2008 +0200 +++ b/dwt/widgets/DateTime.d Fri Aug 22 21:36:05 2008 +0200 @@ -40,6 +40,7 @@ static import tango.text.Util; //static import tango.text.locale.Core; static import tango.text.Text; +static import tango.time.Time; static import tango.time.WallClock; static import tango.time.chrono.Gregorian; static import tango.time.chrono.Calendar; @@ -84,6 +85,17 @@ return instance; } + public this(){ + tango.time.Time.Time time = tango.time.WallClock.WallClock.now(); + tango.time.Time.TimeSpan span = time.time.span; + this.second = span.seconds % 60; + this.minute = span.minutes % 60; + this.hour = span.hours; + auto greg = tango.time.chrono.Gregorian.Gregorian.generic; + this.dayofmonth = greg.getDayOfMonth( time ); + this.month = greg.getMonth( time ); + this.year = greg.getYear( time ); + } int getActualMaximum(int field){ switch( field ){ case YEAR: @@ -288,68 +300,6 @@ } } -/+ -private int getCalendarActualMaximum( tango.time.Time.Time time, int field ){ - int year = cal.getYear( time ); - int month = cal.getMonth( time ); - tango.time.Time.TimeOfDay tod = tango.time.Time.TimeOfDay( time.ticks ); - switch( field ){ - case YEAR: return tango.time.chrono.Gregorian.Gregorian.MAX_YEAR; - case MONTH: return cal.getMonthsInYear( year, tango.time.chrono.Gregorian.Gregorian.AD_ERA ) -1; // Jan is 0, so max is 11 - case DAY_OF_MONTH:return cal.getDaysInMonth( year, month, tango.time.chrono.Gregorian.Gregorian.AD_ERA ) -1; // 1st is 0 - case HOUR:return 23; - case MINUTE:return 59; - case SECOND:return 59; - case AM_PM:return PM; - default: - } -} - -private int getCalendarActualMinimum( tango.time.Time.Time time, int field ){ - switch( field ){ - case YEAR: return 1800; - case MONTH: return 1; - case DAY_OF_MONTH:return 1; - case HOUR:return 0; - case MINUTE:return 0; - case SECOND:return 0; - case AM_PM:return AM; - default: - } -} -private int getCalendarField( tango.time.Time.Time time, int field ){ - switch( field ){ - case YEAR: return cal.getYear( time ); - case MONTH: return cal.getMonth( time ); - case DAY_OF_MONTH:return cal.getDayOfMonth( time ); - default: - } - tango.time.Time.TimeOfDay tod = tango.time.Time.TimeOfDay( time.ticks ); - switch( field ){ - case HOUR:return tod.hours; - case MINUTE:return tod.minutes; - case SECOND:return tod.seconds; - case AM_PM:return tod.hours > 12; - default: - } - assert(false); -} -enum { - AM, - PM, - AM_PM, - HOUR, - MINUTE, - SECOND, - MONTH, - YEAR, - DAY_OF_MONTH, - DAY_SELECTED, - MONTH_CHANGED, - HOUR_OF_DAY -} - -+/ /** * Instances of this class are selectable user interface @@ -371,7 +321,7 @@ * </p><p> * IMPORTANT: This class is <em>not</em> intended to be subclassed. * </p> - * + * * @see <a href="http://www.eclipse.org/swt/snippets/#datetime">DateTime snippets</a> * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a> * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>