Mercurial > projects > dwt-linux
comparison 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 |
comparison
equal
deleted
inserted
replaced
307:9995e4a9d2ee | 308:dc2ae028d2d8 |
---|---|
38 import dwt.dwthelper.utils; | 38 import dwt.dwthelper.utils; |
39 | 39 |
40 static import tango.text.Util; | 40 static import tango.text.Util; |
41 //static import tango.text.locale.Core; | 41 //static import tango.text.locale.Core; |
42 static import tango.text.Text; | 42 static import tango.text.Text; |
43 static import tango.time.Time; | |
43 static import tango.time.WallClock; | 44 static import tango.time.WallClock; |
44 static import tango.time.chrono.Gregorian; | 45 static import tango.time.chrono.Gregorian; |
45 static import tango.time.chrono.Calendar; | 46 static import tango.time.chrono.Calendar; |
46 | 47 |
47 alias tango.text.Text.Text!(char) TangoText; | 48 alias tango.text.Text.Text!(char) TangoText; |
82 } | 83 } |
83 } | 84 } |
84 return instance; | 85 return instance; |
85 } | 86 } |
86 | 87 |
88 public this(){ | |
89 tango.time.Time.Time time = tango.time.WallClock.WallClock.now(); | |
90 tango.time.Time.TimeSpan span = time.time.span; | |
91 this.second = span.seconds % 60; | |
92 this.minute = span.minutes % 60; | |
93 this.hour = span.hours; | |
94 auto greg = tango.time.chrono.Gregorian.Gregorian.generic; | |
95 this.dayofmonth = greg.getDayOfMonth( time ); | |
96 this.month = greg.getMonth( time ); | |
97 this.year = greg.getYear( time ); | |
98 } | |
87 int getActualMaximum(int field){ | 99 int getActualMaximum(int field){ |
88 switch( field ){ | 100 switch( field ){ |
89 case YEAR: | 101 case YEAR: |
90 return 2100; | 102 return 2100; |
91 case MONTH: | 103 case MONTH: |
286 String[] getAmPmStrings(){ | 298 String[] getAmPmStrings(){ |
287 return ampm; | 299 return ampm; |
288 } | 300 } |
289 } | 301 } |
290 | 302 |
291 /+ | |
292 private int getCalendarActualMaximum( tango.time.Time.Time time, int field ){ | |
293 int year = cal.getYear( time ); | |
294 int month = cal.getMonth( time ); | |
295 tango.time.Time.TimeOfDay tod = tango.time.Time.TimeOfDay( time.ticks ); | |
296 switch( field ){ | |
297 case YEAR: return tango.time.chrono.Gregorian.Gregorian.MAX_YEAR; | |
298 case MONTH: return cal.getMonthsInYear( year, tango.time.chrono.Gregorian.Gregorian.AD_ERA ) -1; // Jan is 0, so max is 11 | |
299 case DAY_OF_MONTH:return cal.getDaysInMonth( year, month, tango.time.chrono.Gregorian.Gregorian.AD_ERA ) -1; // 1st is 0 | |
300 case HOUR:return 23; | |
301 case MINUTE:return 59; | |
302 case SECOND:return 59; | |
303 case AM_PM:return PM; | |
304 default: | |
305 } | |
306 } | |
307 | |
308 private int getCalendarActualMinimum( tango.time.Time.Time time, int field ){ | |
309 switch( field ){ | |
310 case YEAR: return 1800; | |
311 case MONTH: return 1; | |
312 case DAY_OF_MONTH:return 1; | |
313 case HOUR:return 0; | |
314 case MINUTE:return 0; | |
315 case SECOND:return 0; | |
316 case AM_PM:return AM; | |
317 default: | |
318 } | |
319 } | |
320 private int getCalendarField( tango.time.Time.Time time, int field ){ | |
321 switch( field ){ | |
322 case YEAR: return cal.getYear( time ); | |
323 case MONTH: return cal.getMonth( time ); | |
324 case DAY_OF_MONTH:return cal.getDayOfMonth( time ); | |
325 default: | |
326 } | |
327 tango.time.Time.TimeOfDay tod = tango.time.Time.TimeOfDay( time.ticks ); | |
328 switch( field ){ | |
329 case HOUR:return tod.hours; | |
330 case MINUTE:return tod.minutes; | |
331 case SECOND:return tod.seconds; | |
332 case AM_PM:return tod.hours > 12; | |
333 default: | |
334 } | |
335 assert(false); | |
336 } | |
337 enum { | |
338 AM, | |
339 PM, | |
340 AM_PM, | |
341 HOUR, | |
342 MINUTE, | |
343 SECOND, | |
344 MONTH, | |
345 YEAR, | |
346 DAY_OF_MONTH, | |
347 DAY_SELECTED, | |
348 MONTH_CHANGED, | |
349 HOUR_OF_DAY | |
350 } | |
351 | |
352 +/ | |
353 | 303 |
354 /** | 304 /** |
355 * Instances of this class are selectable user interface | 305 * Instances of this class are selectable user interface |
356 * objects that allow the user to enter and modify date | 306 * objects that allow the user to enter and modify date |
357 * or time values. | 307 * or time values. |
369 * Note: Only one of the styles DATE, TIME, or CALENDAR may be specified, | 319 * Note: Only one of the styles DATE, TIME, or CALENDAR may be specified, |
370 * and only one of the styles SHORT, MEDIUM, or LONG may be specified. | 320 * and only one of the styles SHORT, MEDIUM, or LONG may be specified. |
371 * </p><p> | 321 * </p><p> |
372 * IMPORTANT: This class is <em>not</em> intended to be subclassed. | 322 * IMPORTANT: This class is <em>not</em> intended to be subclassed. |
373 * </p> | 323 * </p> |
374 * | 324 * |
375 * @see <a href="http://www.eclipse.org/swt/snippets/#datetime">DateTime snippets</a> | 325 * @see <a href="http://www.eclipse.org/swt/snippets/#datetime">DateTime snippets</a> |
376 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a> | 326 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a> |
377 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | 327 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> |
378 * | 328 * |
379 * @since 3.3 | 329 * @since 3.3 |