Localization for DayOfWeek(DateTime date)

Stimulsoft Reports.NET discussion
Post Reply
STB
Posts: 5
Joined: Fri Jul 17, 2009 1:20 pm
Location: Germany

Localization for DayOfWeek(DateTime date)

Post by STB »

Hello together

i am in search for a solution to localize the output of the "DayOfWeek(DateTime date)" function.

At the moment, when I make a output from something like "{DayOfWeek(Today)}", this outputs "Tuesday". But I need a localization into german for this, where the Tuesday is called "Dienstag".

How do I localize the output from "DayOfWeek" to the german language ?

Thanks for any advise!

With greetings from germany! :-)
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Localization for DayOfWeek(DateTime date)

Post by Jan »

Hello,

You can add your own function directly to report. Something like this:

Code: Select all

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using Stimulsoft.Controls;
using Stimulsoft.Base.Drawing;
using Stimulsoft.Report;
using Stimulsoft.Report.Dialogs;
using Stimulsoft.Report.Components;

namespace Reports
{
    
    public class Report : Stimulsoft.Report.StiReport
    {

       string MyDayOfWeek(DateTime date) 
       {
               switch(date.DayOfWeek)
               {
                     case DayOfWeek.Sunday: 
                         return "......"; 
                } 

       }
        
        public Report()
        {
            this.InitializeComponent();
        }......
After then you can write in expression:

Code: Select all

{MyDayOfWeek(date)}
Also in new version 2010.1 (when it will be available) you can check extended version of this function:

Code: Select all

{DayOfWeek(date, true)}
Thank you.
STB
Posts: 5
Joined: Fri Jul 17, 2009 1:20 pm
Location: Germany

Localization for DayOfWeek(DateTime date)

Post by STB »

Jan wrote:Hello,

You can add your own function directly to report. Something like this:
Hello and thanks for your suggestion. I try'd it out and, for the first, this works out.

But, looking ahead, I have some users that will create their own reports through the designer with no knowledge (and access) to the code tab.
Is there no "better" way, possible like setting a localization or something else for date/time conversions which will use the german culture of the operating system to make this and affects the build-in DayOfWeek Function ?
Brendan
Posts: 309
Joined: Sun Jul 16, 2006 12:42 pm
Location: Ireland

Localization for DayOfWeek(DateTime date)

Post by Brendan »

MSDN documentation suggests the following if it's of any help:
The members of the DayOfWeek enumeration are not localized. To return the localized name of the day of the week, call the DateTime.ToString(String) or the DateTime.ToString(String, IFormatProvider) method with either the "ddd" or "dddd" format strings. The former format string produces the abbreviated weekday name; the latter produces the full weekday name.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Localization for DayOfWeek(DateTime date)

Post by Jan »

Hello,
STB wrote:
Jan wrote:Hello,

You can add your own function directly to report. Something like this:
Hello and thanks for your suggestion. I try'd it out and, for the first, this works out.

But, looking ahead, I have some users that will create their own reports through the designer with no knowledge (and access) to the code tab.
Is there no "better" way, possible like setting a localization or something else for date/time conversions which will use the german culture of the operating system to make this and affects the build-in DayOfWeek Function ?
In this case you need wait new release (2010.1) with overloaded version of DayOfWeek function.

Thank you.
Post Reply