Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Calendar and DateTimeCalendar and DateTime
Previous
 
Next
New Post
9/11/2007 5:28 AM
 

Hello,

I'm creating a DotNetNuke module using C#. I use the DotNetNuke popup calendar to insert a date in a textbox. When the user choose a language for the site, the calendar automatically format the date for the selected language. So, if I choose "Italian" I've dd/mm/yyyy, if I choose "English" I've mm/dd/yyyy. When I convert the string in a DateTime, Convert.ToDateTime accepts both formats. But if I want to use the date, I suppose I've to memorize  it in a unique format (italian or american). Assuming I memorize it in italian format: I've to re-format the american date before I memorize it, and re-format the italian date memorized if I wanto to display it when the English language is selected.

So the question is:

Has DotNetnuke some features for the date management?

Please help me, I'm new to DotnetNuke and I really need your help.

 

 
New Post
9/11/2007 5:41 AM
 

I hope that code helps: (it is from UDT DateTime)

Public Overrides Property Value() As String
    Get
        Dim D, T As DateTime
        If ctlDate.Value = "" And ctlTime.Value = "" Then Return ""
        If IsDate(ctlDate.Value) And IsDate(ctlTime.Value) Then
            D = DateTime.Parse(ctlDate.Value)
            T = DateTime.Parse(ctlTime.Value) 'ctlTime.value returns non-normalized time (see constructor)
            D = New DateTime(D.Year, D.Month, D.Day, T.Hour, T.Minute, T.Second)
            If convertTimezone AndAlso HttpContext.Current.Request.IsAuthenticated Then
                Dim objUser As UserInfo = UserController.GetCurrentUserInfo
                Dim UserTime As New Entities.Users.UserTime
                D = UserTime.ConvertToServerTime(D, objUser.Profile.TimeZone)
            End If
            Return D.ToString("s")
        Else
            Return ctlDate.Value & " " & ctlTime.Value 'invalid Value
        End If
    End Get

    Set(ByVal Value As String)
        If IsDate(Value) Then
            Dim d As DateTime = DateTime.Parse(Value)
            If convertTimezone AndAlso HttpContext.Current.Request.IsAuthenticated Then
                Dim objUser As UserInfo = UserController.GetCurrentUserInfo
                Dim UserTime As New Entities.Users.UserTime
                d = UserTime.ConvertToUserTime(d, objUser.Profile.TimeZone)
                Value = d.ToString("s")
            End If
        End If
        ctlDate.Value = Value
        ctlTime.Value = Value
    End Set
End Property
 
New Post
9/11/2007 8:15 AM
 

Hi Stefan, thanks for your very fast response.  

Can you please tell me where is the code that you have posted? DotNetNuke has an own DateTime type? (I use DNN 4.5.3)

And Can you write an example on how can I solve my problem?

Be patient, it's only few months I'm programming...

Thanks.

 
New Post
9/11/2007 9:01 AM
 

The code is pasted from the UDT module (User Defined Table, a simple core modul)

I chose this code because it shows some tricks. Look at the get part, here are date and time  in their own textboxes. We parse the text to return the date informatio which is still al localized string and it is from the timezone of the current user. So we convert that time again to Server time. At last, as we store everything in a big text column (the price of offering an universal table) as string. We use therefore the "s" format which looks like 2007-11-09T15:31:22. This string is culture neutral.

Setting is the other way round. We take the string, parse it as datetime and convert it back to user time. Afterwards we use also string.format (not part of my example) to fill the textboxes with a localized date again.

DotnetNuke helps you with the Class Usertime to fullfill the timezone conversions. All other stuff is part of the .Net framework.

 
New Post
9/11/2007 9:19 AM
 

You are very kind Stefan.

So, is this code correct?

DateTime dt=new DateTime();
dt= Convert.ToDateTime(txtMyDate.Text);
if (HttpContext.Current.Request.IsAuthenticated)
{
UserInfo objUser= UserController.GetCurrentUserInfo;
UserTime UserTim = new UserTime();
dt=UserTim.ConvertToServerTime(dt, objUser.Profile.TimeZone);
objInfo.CreatedDate=dt;
}

Thank you very much!

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Calendar and DateTimeCalendar and DateTime


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out