Adjusting times from database(timezone,dates)

Posts   
 
    
Anthony
User
Posts: 155
Joined: 04-Oct-2006
# Posted on: 29-Jun-2008 07:17:09   

I am storing all times in UTC(GMT) time. When i retrieve a collection, i wish to be adjust all datetime fields by a specific amount of minutes.

Can i override a method to do this or do i have to loop through the collection and adajust the values?

llblgen v2.5,dotnet2,adapter model

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 30-Jun-2008 01:10:48   

Hi Anthony,

You can do that, however I wouldn't modify the original value as this could be confused and will make the entity dirty. Instead I would create a new property for reflect the adjusted date-time:

public partial class SomeEntity
{
     public DateTime MyLocalDate
     {
          DateTime myLocalDate = DateTime.Now();

          if (MyUTCDate != null)
          {
                myLocalDate  = MyUTCDate.AddHours(xxx);
          }

           return myLocalDate;
     }
}

Then somewhere you could use both members (the original field and the new property);

DateTime myOriginalDate = someEntity.MyUTCDate;
DateTime myLocalDate = someEntity.MyLocalDate;

This should work for databinding as well simple_smile

Let us know if this work for you.

David Elizondo | LLBLGen Support Team
Anthony
User
Posts: 155
Joined: 04-Oct-2006
# Posted on: 30-Jun-2008 16:07:35   

thanks..that odes the trick