33 lines
802 B
Plaintext
33 lines
802 B
Plaintext
![]() |
include::../why-dotnet.adoc[]
|
||
|
|
||
|
include::../impact-dotnet.adoc[]
|
||
|
|
||
|
include::../how-dotnet.adoc[]
|
||
|
|
||
|
=== Code examples
|
||
|
|
||
|
==== Noncompliant code example
|
||
|
|
||
|
[source,csharp,diff-id=1,diff-type=noncompliant]
|
||
|
----
|
||
|
void PrintTime()
|
||
|
{
|
||
|
Console.WriteLine(DateTime.UtcNow.ToString("dd/MM/yyyy HH:mm:ss"));
|
||
|
|
||
|
Console.WriteLine(DateTime.UtcNow.ToString("dd/mm/yyyy HH:MM:ss")); // Months and minutes have changed their places
|
||
|
}
|
||
|
----
|
||
|
|
||
|
==== Compliant solution
|
||
|
|
||
|
[source,csharp,diff-id=1,diff-type=compliant]
|
||
|
----
|
||
|
void PrintTime()
|
||
|
{
|
||
|
Console.WriteLine(DateTime.UtcNow.ToString(CultureInfo.GetCultureInfo("es-MX")));
|
||
|
|
||
|
Console.WriteLine(DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)); // Better provide a well known culture, so this kind of issues do not pop up
|
||
|
}
|
||
|
----
|
||
|
|
||
|
include::../resources-dotnet.adoc[]
|