We have a pipeline which builds, tests and outputs some artefacts to nuget. After an initial push of the existing codebase (C#), the tests fail in the pipeline where .ToString() is called on a DateTime object, it returns mm/dd/yyyy rather than the UK format dd/mm/yyyy as per our local developer machines where the tests pass OK. I can think of 4 ways to overcome this but what is best practice and how has anyone else overcome this?

  • Set CultureInfo.DefaultThreadCurrentCulture at various points in the code
  • Set default culture in yaml or pipeline settings?
  • Set default culture in app.config of the unit tests profile
  • Change everyone ToString() to ToString("dd/mm/yyyy") (far from ideal!
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.