Invalid DateTime format after website publish on IIS - datetime-format

I know there are numerous posts on this issue but none worked for me and hence I thought to post one by myself. I hope I am not spamming.
All I want to do is to convert string into a DateTime object. It worked fine on VS Web Develpoment Server but when I published it to IIS it started throwing the exception "String was not recognized as a valid DateTime." I went through numerous posts and tried following code but they all failed. For simplicity I hard coaded the DateTime string. Please note, format of DateTime in the string is fixed, I have to use that only.
Convert.ToDateTime("27-6-2012 9:05 PM")
// Just for the sake of it I also used CurrentUICulture and InstalledUICulture in the line below.
// Note: For me CurrentCulture = CurrentUICulture = InstalledUICulture = en-US
Convert.ToDateTime("27-6-2012 9:05 PM", CultureInfo.CurrentCulture)
DateTime.Parse("27-6-2012 9:05 PM")
// Just for the sake of it I also used CurrentUICulture and InstalledUICulture in the line below.
// Note: For me CurrentCulture = CurrentUICulture = InstalledUICulture = en-US
DateTime.Parse("27-6-2012 9:05 PM", CultureInfo.CurrentCulture)
// Just for the sake of it I also used CurrentUICulture and InstalledUICulture in the line below.
// Note: For me CurrentCulture = CurrentUICulture = InstalledUICulture = en-US
DateTime.ParseExact("27-6-2012 9:05 PM", "{0:d-M-yyyy h:mm tt}", CultureInfo.CurrentCulture)
Then just for experinment I changed format of the date in string to "6/27/2012 9:05 PM". I found all of the above worked except DateTime.ParseExact. For me if any one of the above codes work, I am good but the problem is that I cannot change the format of date in the string, that comes as a parameter which is not in my control.
This looks like such a trivial issue but I don't know what is it that I am missing? It is so embarrassing. Can anyone help me please?
Thanks in advance.

It's possible that the regional settings on the server are not the same as on your dev environment. Try this. http://support.microsoft.com/kb/241671
EDIT - Look in control panel under the regional settings. This will effect how the server reads dates.

Related

Calendar locale (German) for PlantUML gantt diagrams

Can someone tell me, how I can define another calendar's locale (e.g. German) for the rendered calendar parts of the nice gantt feature in plantUML
I have something like:
#startgantt
-- Vorbereitung --
Project starts 2020-12-01
[Themenfindung] starts 2020-12-01 and ends 2021-01-01
[milestone] happens at 2020-12-15
-- ... --
#endgantt
The output prints month and daynames in English:
Is it possible at all and if so how can this be changed to German.
There is nothing about this in the documentation (https://plantuml.com/de/gantt-diagram).
With last beta http://beta.plantuml.net/plantuml.jar you can now specify a language for the Calendar.
For example:
#startgantt
Language DE
Project starts the 20th of september 2017
...
#endgantt
This will be integrated in next official release.
According to their source code,
there are hardcoded values for days and months as Enums
and they use name() method to get their English names.
I would recommend you to clone their repo and change the hardcoded values in two classes:
In file src/net/sourceforge/plantuml/project/time/DayOfWeek.java
replace method shortName like this:
public String shortName() {
Locale locale = Locale.getDefault();
String s = StringUtils.capitalize(java.time.DayOfWeek.valueOf(this.toString()).getDisplayName(TextStyle.SHORT_STANDALONE, locale));
return s.substring(0,2);
}
In file src/net/sourceforge/plantuml/project/time/Month.java
replace two methods like this
public String shortName() {
return StringUtils.capitalize(java.time.Month.valueOf(this.toString()).getDisplayName(TextStyle.SHORT_STANDALONE,Locale.getDefault()));
}
and
public String longName() {
return StringUtils.capitalize(java.time.Month.valueOf(this.toString()).getDisplayName(TextStyle.FULL_STANDALONE,Locale.getDefault()));
}
I compile only these two classes and replace them in jar file. This works for me.
Mike.

default locale change, version 5.0.1 -> 5.1

(sorry my english) Hi.
With 5.0.1, the default short date format for locale "es" (in config.json) return this date format "10/01/2017"
With 5.1, the default short date format for locale "es" (in config.json) return this date format "10 ene. 2017".
I think is a coherent change. But I need keep working with the old format. So, where I must touch to get the old format in a entire new 5.1 qooxdoo project?
I mean, where this locale format is defined? I was trying found where but I can't.
Or any other solution.
thanks
This snippet works for us
this._localeManager = qx.locale.Manager.getInstance();
this._localeManager.addLocale("el", {
"cldr_date_format_short": "dd/MM/yyyy" // Override short date format for Greek
});

Get week day in portuguese language from date in moment js

This is my code
$scope.getWeekDayShort = function(date) {
moment().locale('pt-br');
return moment(date, "D_M_YYYY").format('ddd');
}
it returns name of weekday in english but need portuguese weekday name
If I pass 1_1_2015 it returns Thu
How can I get weekday name in portuguese?
EDIT
moment.locale('pt-br');
console.log(JSON.stringify(moment.months())) // ["janeiro","fevereiro","março","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"]
moment.locale('en');
console.log(JSON.stringify(moment.months())); // ["January","February","March","April","May","June","July","August","September","October","November","December"]
I have included moment-with-locales.min.js file which includes all supported language data and it work good with upper code. So why it not works with week name ?
Try this (source):
moment(date, "D_M_YYYY").locale('pt-br').format('ddd')
Might be worth it to log an issue on the GitHub page, I think your code should work or the docs should be improved.

How do I format a string while using a BindingSource?

Technology: Visual Studio 2008 .NET, Winforms
bsTransactions.DataSource = Transactions.Tables[2];
bsnTransactions.BindingSource = bsTransactions;
txtTransOverrideDate.DataBindings.Add("Text", bsTransactions, "TransactionDate", true,DataSourceUpdateMode.Never, "", "MM/dd/yyyy");
Currently, I'm getting an error saying that the string wasn't a recognized DateTime string. Despite the fact that if I get the column type from
Transactions.Tables[2].Rows[0]["TransactionDate"].DataType.ToString();
returns "System.DateTime" and the actual value looks like "1/23/2010 12:00:00 AM"
I'm trying to format a string that currently looks like "1/23/2010 12:00:00 AM" to only show the date.
The catch is, there's a BindingSourceNavigator being use, so just applying the formatting to the textbox after the fact only applies to the first value, but not any others that are navigated to using the bindingNavigator.
I have a feeling that using the "bsTransactions" to applies bindings to the textbox, it's changing the datatype, hence it not being recognized as a DateTime.
txtTransOverrideDate.DataBindings.Add("Text", bsTransactions, "TransactionDate", true,DataSourceUpdateMode.Never, "", "MM/dd/yyyy");
I made changes in the original post to mimic this, but this is the answer.

Localization, how to use a specific resx

Today I'm playing with localization. I have a winforms app where I've set localizable to true on my screen, then I went and converted all the text to spanish as best as I could. So now I have my screen.resx and my screen.es.resx and everything looks good/bueno. How do I now run my app and have the spanish version come up? I tried going into regional and language options and setting my 'standards and formats' option to spanish. Now my dates are in spanish which is good, but the text on my app is still the english version. How do I get this thing to load with my screen.es.resx?
Did you set your applications Culture/UI Culture to Spanish?
In following code, en-US will be replaced by your UI culture and it will use appropriate resx file depending on the way you have them set up
HTH
System.Globalization.CultureInfo myCI = new System.Globalization.CultureInfo("en-US", false);
System.Threading.Thread.CurrentThread.CurrentUICulture = myCI;
System.Threading.Thread.CurrentThread.CurrentCulture = myCI;
You control which language resource that are used by setting the CurrentUICulture of the current thread. You will most likely also want to set the CurrentCulture (that controls number and date formats and such) (C# code):
// the following using statements must be present
// using System.Threading;
// using System.Globalization;
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("es-ES");
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture;
For a more detailed discussion on the difference between CurrentUICulture and CurrentCulture, there is a blog post by Michael Kaplan on the topic.

Resources