This project has moved and is read-only. For the latest updates, please go here.

Small code improvement in Trigger.cs

Topics: Errors
Feb 26, 2013 at 9:04 AM
Edited Feb 26, 2013 at 9:05 AM
After some tests, I've found that creating a scedule in Windows Vista+ when the system language has interesting calendars, it fails with a COM Exception refering to StartBoundary with a bad GregorianUS date.

Let's say the example of having a GregorianUS date, 26/02/2013, now we change it to ArabicSA date and it will be ##/##/14## (# is a number), and then schtasks will not accept the date.

The text conversion of dates between calendars is different on most times, however, sould the DateTime variables values of diferent calendars change? The answer is NO. The only thing that will change is the ToString way to work and format the text of the time contained.

Since schtasks only accepts GregorianUS dates, why not simply change the values assigned and bounded of StartBoundary and EndBoundary properties in Trigger.cs? The only thing needed is change ToString(V2BoundaryDateFormat) to ToString(V2BoundaryDateFormat, CultureInfo.CreateSpecificCulture("en-US"))

Lines to be changed are 252, 373 and 646 in the Trigger.cs file, after this everything Works OK.

To test the error, date time system format can be changed to Arabic, then only add a task that contains a daily schedule for example. After the changes to Trigger.cs there are no errors.

Posted this as error, don't know if it's right...!
Feb 26, 2013 at 4:07 PM
Thanks for solving this problem. I have incorporated your suggested changes into the code and will be testing them as part of the next release (1.9.4).
Feb 26, 2013 at 7:35 PM
Edited Feb 26, 2013 at 8:45 PM
Excelent!

And congrats for this Project, very usefull!
Feb 26, 2013 at 11:39 PM
In case you are using your modified code for your project, I have already found some other related code changes. First, there is a line in Task.cs that is similar to those in Trigger.cs that needs a similar change. For every DateTime.Parse call (usually paired to the ToString calls in properties), you also need to also add the CultureInfo parameter.
Feb 27, 2013 at 12:06 AM
Good to know. Thinking on wait unill next release hehe :D