SmartDate Issue

SmartDate Issue

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


Akhilesh Verma posted on Thursday, November 28, 2013

Hi,

I am using CSLA 3.8 version. In this version I am facing some date time conversion issues with SmartDate.

 

For Example:-

Host environment has Date format as “DD/MM/YYYY”

Client environment has Date format as “MM/DD/YYYY”.

 

Case 1

a.     A SmartDate object is created at host for the value “6 July 2013”.

b.    The object will store information in string format as “06/07/2013”.

 

Result: When this object is queried at UI, it will convert string value to datetime type object, which will return “7 June 2013”.

 

 

Case 2

a.     A SmartDate object is created at host for the value “26 July 2013”.

b.    The object will store information in string format as “26/07/2013”.

 

Result: When this object is queried at UI, it will try to convert string value to datetime type object, which will return a null value. This will cause an exception at the UI.

 

Case 3

a.     A business object is using SmartDate type property to save date information to database.

b.    Another object is using DateTime type property to get date information from the same database.

 

Result: Return value will be different from the original one.

To address the same I have modified SmartDate class. I request to support team to review my changes in attached file(rename it .cs) and let me know the changes are not going to crash the framework in any scenario. 

JonnyBee replied on Thursday, November 28, 2013

No,

I do not agree and we are NOT planning on doing any update on the 3.8.x versions of CSLA.

SmartDate stores its value in a DateTime object (NOT a string) and the default format for convcertion to string is "d" which is the short data format. So it seems that your SmartDate code is modified on your side. Even the SmartDate.cs from 2005 uses a DateTime backing field to store its value and we are talking Csla 2.x version at that time.

 

So I would rather suggest that you grab the latest SmartDate.cs from CSLA 3.8 .3 and update your own CSLA version.

See: http://www.lhotka.net/cslacvs/viewvc.cgi/core/branches/V3-8-x/cslacs/Csla/SmartDate.cs?revision=4288&view=markup

Copyright (c) Marimer LLC