swagger-api / swagger-api/swagger-codegen
DateTime Format is not Culture Invariant
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Serverside expects DateTimeFormat in "dd/MM/yyyy"
As my client system has culture "de-CH", Setting the Clients DateTimeFormat to "dd/MM/yyyy"
Will still lead to formatting the Date in the following Format: "dd.MM.yyyy". The following format string will work: "dd'/'MM'/'yyyy"
See custom format specifier: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings
Client Code Generation: CSharp
Swagger-codegen version
master
Swagger declaration file content or url
Applies to any date
- in: header
name: bis
description: >-
Tag, bis dem die angegebene Aenderung gelten soll. Wenn nicht
vorhanden gilt die Aenderung bis alle Ewigkeit
required: false
type: string
format: date
Command line used for generation
Steps to reproduce
any date time formatting
Related issues/PRs
None found
Suggest a fix/enhancement
Suggestion:
This would in any circumstances lead to the specified format:
return ((DateTime)obj).ToString (Configuration.DateTimeFormat, CultureInfo.InvariantCulture);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache around line 292, where the issue identifies DateTime formatting. Reproduce generation with a de-CH culture and a date format of dd/MM/yyyy; done means the generated C# client preserves the configured separators regardless of the client culture.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100