Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anders Dahl Tollestrup 73 posts 52 karma points
    Feb 11, 2011 @ 16:09
    Anders Dahl Tollestrup
    0

    Multilingual dayname

    I'm bulding a new blog in umbraco and would like to use the dayname() method to display the name of the post date. 

    http://wifi.umbraco.org/wiki/reference/exslt/exsltexsltdatesandtimes/dayname

    It works just fine, but no matter what language i'm using on the site, the dayname() method shows the dayname in english.

    Is the dayname() method not prepared to multilingual sites ?

     

  • Tobias Morf 80 posts 183 karma points
    Feb 11, 2011 @ 16:46
    Tobias Morf
    0

    No, it's not...

    http://msdn.microsoft.com/en-us/library/system.datetime.dayofweek.aspx

    Here is the umbraco implementation:

      /// <summary>
      /// Implements the following function
      ///   string date:day-name()
      /// </summary>
      /// <returns>The name of the current day</returns>
      public static string dayname(){
       return DateTime.Now.DayOfWeek.ToString();
      }
      /// <summary>
      /// Implements the following function
      ///   string date:day-name(string)
      /// </summary>
      /// <returns>The name of the day of the specified date or the empty string if the
      /// date is invalid</returns>
      public static string dayname(string d){
       try{
        DateTime date = DateTime.Parse(d);
        return date.DayOfWeek.ToString();
       }catch(FormatException){
        return "";
       }
      }
Please Sign in or register to post replies

Write your reply to:

Draft