Enhanced SmartDate for 3.7.0 and above

Enhanced SmartDate for 3.7.0 and above

Old forum URL: forums.lhotka.net/forums/t/7686.aspx


tiago posted on Sunday, September 27, 2009

Hi all,

This is one of my standard changes to Csla sources. I just replace the ..\cslalightcs\cslacs\Csla\SmartDate.cs file with the one in attached zip. It features some extras

Accepted separators (extra)
" " (space)
"-"
"."
","
"/"
"\"
NB - Different separators can be mixed. When using separators, the zero isn't needed (on days and months < 10).

Accepted no separator (extra)
- 4 digits exactly (current year)
- 8 digits exactly
NB - Order of day / month / year according to CurrentInfo.ShortDatePattern.


Abbreviated forms (extra)
NNsNN where
- s is the any of the above separators
- NN refers to day number and month number according to CurrentInfo.ShortDatePattern

Standard relative dates
"." - today
"-" - yesterday
"+" - tomorrow

Relative dates (extra)
"<" - one month ago
">" - one month from now
"+nnn..." - nnn... days from now
"-nnn..." - nnn... day ago
"<nn" - nn day of last month
">nn" - nn day of next month
"nn" - nearest nn day (if we are the 25th, 5 is the 5th of next month)

Concerning the accepted separators, I really don't remember exactly how the standard SmartDate behaves but I guess it only accepts the CurrentInfo.DateSeparator

Standard .NET framework TryParse magic still works.

Rocky, can this be merged into the standard Csla?

ozitraveller replied on Sunday, September 27, 2009

Attached?

tiago replied on Monday, September 28, 2009

Oops... I forgot attachments get lost when you edit a post

JonnyBee replied on Sunday, September 27, 2009

Hi Tiago,

I would like to add this code to the CslaContib projects on Codeplex. Yhis SmartDate would work great with my SmartDateTimePicker that accepts text input and uses SmartDate.Parse to transform to a datetime.

Your attachment is missing so please repost and state wheter I can add it to CodePlex too.

/jonnybee
CslaContrib coordinator

tiago replied on Monday, September 28, 2009

Yes, you can add it to CslaContrib project.

Copyright (c) Marimer LLC