Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 336275

Summary: SWTBotDateTime fails to set date completely when day-of-month to set is not available in current month
Product: [Technology] SWTBot Reporter: Marc Philipp <mail>
Component: SWTBotAssignee: Project Inbox <swtbot-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: mail
Version: 2.0.2   
Target Milestone: 2.0.3   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
mylyn/context/zip none

Description Marc Philipp CLA 2011-02-03 14:20:59 EST
Build Identifier: M20100909-0800

Given a DateTime control with a currently set month that has less than 31 days (e.g. currently set date is 2/3/2011) when you try to set a date that has a day of month of 31 (e.g. 12/31/2010) then only the month and year of the date to be set are updated, the day of month stays at its initial value.

Looking at the code of SWTBotDateTime#setDate(Date) it looks like the order of method calls on the widget is wrong: setYear, setDay, and then setMonth. It should be setYear, setMonth, and then setDay.

Reproducible: Always

Steps to Reproduce:
1. Set the date of a DateTime widget to 2/3/2011 in (3rd February 2011)
2. Call setDate( new Date( 110, 11, 31 )) on the SWTBotDateTime instance representing the DateTime widget
3. The date is set incorrectly to 12/3/2010 (3rd December 2010)
Comment 1 Ketan Padegaonkar CLA 2011-02-03 15:09:36 EST
Fixed in revision f86c968. See https://github.com/ketan/SWTBot/commit/f86c968 for the fix and test case.
Comment 2 Ketan Padegaonkar CLA 2011-02-03 15:09:38 EST
Created attachment 188270 [details]
mylyn/context/zip
Comment 3 Ketan Padegaonkar CLA 2011-02-03 15:22:17 EST
Sorry, that would be revision b918d9e55d27df81d32cb1030457db07815f23c6 and not f86c968 as I mentioned in previous commit.
Comment 4 Marc Philipp CLA 2011-02-03 15:25:04 EST
Wow, that was fast! Thanks!