Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better (consistent) programmatic access to standard patterns #138

Closed
GoogleCodeExporter opened this issue Mar 15, 2015 · 8 comments
Milestone

Comments

@GoogleCodeExporter
Copy link

InstantPattern has GeneralPattern, which is an ISO (and roundtrip) pattern 
using the invariant culture.
LocalDatePattern has IsoPattern, which is an ISO (and roundtrip) pattern using 
the invariant culture.
OffsetPattern has GeneralInvariantPattern(WithZ), which is a roundtrip pattern 
using the invariant culture.
PeriodPattern has RoundtripPatten, which is a roundtrip pattern using the 
invariant culture.

I'm not sure why InstantPattern.GeneralPattern isn't InstantPattern.IsoPattern, 
but even so, it seems to me that there's a lot of inconsistency here.

Original issue reported on code.google.com by malcolm.rowe on 2 Nov 2012 at 9:47

@GoogleCodeExporter
Copy link
Author

It's worth noting that for InstantPattern, the general pattern as defined by 
the "g" standard format specifier is indeed ISO... whereas LocalDatePattern 
doesn't *have* a "g" standard format specifier. LocalDateTimePattern does, but 
it's not ISO... (and it's not invariant).

Basically, we have three concepts - roundtrip, general (i.e. general standard 
format pattern, "g"), and ISO. In some cases they coincide, in others they 
don't. How should we name them in code?

One thing we *may* want to do is create a factory method / property 
corresponding to every standard format pattern in every type. So we could have 
LocalDatePattern.GetShortPattern(CultureInfo) for example.

Arguably we could also have a new type "Patterns" such that you could have:

    Patterns.GetShortDatePattern
    Patterns.GetLongDatePattern
    Patterns.GetShortDateTimePattern
    // etc

Admittedly the name "Patterns" is already a namespace name, which doesn't help.

We may well want to punt this until v1.1 though. Really not sure what to do 
with the current properties...

Original comment by jonathan.skeet on 3 Nov 2012 at 7:28

@GoogleCodeExporter
Copy link
Author

Good catch, Richard. (If we don't get round to fixing the docs before 1.0, 
that's okay - but obviously we should do so soon.) It still irks me that 
ISO-8601 recommends using "," as the deicmal separator, when I've *never* seen 
that in the real world. I don't think we handle that when parsing, either...

Original comment by jonathan.skeet on 5 Nov 2012 at 6:59

@GoogleCodeExporter
Copy link
Author

It's a common decimal separator *for numbers* in various countries, but I've 
never seen it used *in times* as ISO suggests.

Originally we made "." in a time-related pattern map to the culture-specific 
decimal separator, but I changed back to always using "." as that's what the 
BCL does. Note that our ISO patterns are invariant, so it sort-of makes sense 
for them to use a dot... but it does mean we couldn't parse examples from 
ISO-8601 itself. Hmm. (Probably worth this all going into a separate issue...)

Original comment by jonathan.skeet on 5 Nov 2012 at 7:48

@GoogleCodeExporter
Copy link
Author

This will take significant thought, and should be done properly. The existing 
state of play isn't abysmal, just inconsistent. Will leave as-is for 1.0.

In 1.1 we should create a new and whizzy set of consistent conventions, 
deprecating any names we don't like any more.

In 2.0 we can then remove the obsolete names.

Original comment by jonathan.skeet on 6 Nov 2012 at 9:35

  • Changed title: Provide better (consistent) programmatic access to standard patterns
  • Added labels: Milestone-1.1-consider
  • Removed labels: Milestone-1.0

@GoogleCodeExporter
Copy link
Author

Original comment by malcolm.rowe on 10 Nov 2012 at 9:37

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

Original comment by malcolm.rowe on 10 Nov 2012 at 4:57

@GoogleCodeExporter
Copy link
Author

Original comment by malcolm.rowe on 25 Jan 2013 at 8:33

  • Added labels: Milestone-1.2.0
  • Removed labels: Milestone-1.1-consider

@GoogleCodeExporter
Copy link
Author

I think we're done until 2.0 now - the names may not be ideal, but they're not 
awful.

More static methods for *creating* patterns would be feasible, but needn't be 
targeted at a particular release.

Original comment by jonathan.skeet on 25 Sep 2013 at 8:21

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants