Automatic dates (client side) » History » Version 8
Pablo Alingery, 20/04/2012 10:21
| 1 | 1 | Pablo Alingery | h1. Automatic dates (client side) |
|---|---|---|---|
| 2 | 1 | Pablo Alingery | |
| 3 | 8 | Pablo Alingery | Afin que les dates dans un formulaire soient toujours d1 =today-8 days et d2 =today, il faut faire ce qui suit. |
| 4 | 7 | Elie Soubrie | Ajout dans le fichier source:workspace/client-public/js/components/commons/forms/components/singleSelection/DateBetween.js@2#L34 |
| 5 | 1 | Pablo Alingery | |
| 6 | 2 | Pablo Alingery | <pre><code class="javascript"> |
| 7 | 1 | Pablo Alingery | var date1 = new Date(); |
| 8 | 1 | Pablo Alingery | var numberOfDaysToRemove= 8; |
| 9 | 1 | Pablo Alingery | date1.setDate(date1.getDate()-numberOfDaysToRemove); |
| 10 | 1 | Pablo Alingery | date1.setHours(0, 0, 0, 0) |
| 11 | 1 | Pablo Alingery | this.fieldFrom = new Ext.form.DateField({ |
| 12 | 1 | Pablo Alingery | allowBlank : true, |
| 13 | 1 | Pablo Alingery | format : dateFormat, |
| 14 | 1 | Pablo Alingery | flex : 1, |
| 15 | 1 | Pablo Alingery | //height : this.height, |
| 16 | 1 | Pablo Alingery | //value : new Date(this.defaultValues[0]).format(dateFormat), |
| 17 | 1 | Pablo Alingery | //value : new Date("2010/09/02 23:00:00").format(dateFormat), |
| 18 | 1 | Pablo Alingery | value : date1.format(dateFormat), |
| 19 | 1 | Pablo Alingery | showTime : this.showTime |
| 20 | 1 | Pablo Alingery | }); |
| 21 | 1 | Pablo Alingery | var date2 = new Date(); |
| 22 | 1 | Pablo Alingery | date2.setHours(0, 0, 0, 0); |
| 23 | 1 | Pablo Alingery | this.fieldTo = new Ext.form.DateField({ |
| 24 | 1 | Pablo Alingery | allowBlank : true, |
| 25 | 1 | Pablo Alingery | format : dateFormat, |
| 26 | 1 | Pablo Alingery | flex : 1, |
| 27 | 1 | Pablo Alingery | //height : this.height, |
| 28 | 1 | Pablo Alingery | //value : new Date(this.defaultValues[1]).format(dateFormat), |
| 29 | 1 | Pablo Alingery | value : date2.format(dateFormat), |
| 30 | 1 | Pablo Alingery | showTime : this.showTime |
| 31 | 1 | Pablo Alingery | }); |
| 32 | 2 | Pablo Alingery | </code></pre> |