|
3 | 3 | objc-nsdate-formatter |
4 | 4 | ===================== |
5 | 5 |
|
6 | | -When ``NSDateFormatter`` is used to convert an ``NSDate`` type to a ``String`` type, the user |
7 | | -can specify a custom format string. Certain format specifiers are undesirable |
8 | | -despite being legal. See http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns for all legal date patterns. |
| 6 | +When ``NSDateFormatter`` is used to convert an ``NSDate`` type to a ``String`` |
| 7 | +type, the user can specify a custom format string. Certain format specifiers |
| 8 | +are undesirable despite being legal. |
| 9 | +See http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns |
| 10 | +for all legal date patterns. |
9 | 11 |
|
10 | | -This checker reports as warnings the following string patterns in a date format specifier: |
| 12 | +This checker reports as warnings the following string patterns in a date |
| 13 | +format specifier: |
11 | 14 |
|
12 | | -#. yyyy + ww : Calendar year specified with week of a week year (unless YYYY is also specified). |
| 15 | +#. yyyy + ww : Calendar year specified with week of a week year |
| 16 | + (unless YYYY is also specified). |
13 | 17 |
|
14 | | - * | **Example 1:** Input Date: `29 December 2014` ; Format String: `yyyy-ww`; |
| 18 | + * | **Example 1:** Input Date: `29 December 2014` ; |
| 19 | + | Format String: `yyyy-ww`; |
15 | 20 | | Output string: `2014-01` (Wrong because it’s not the first week of 2014) |
16 | 21 |
|
17 | | - * | **Example 2:** Input Date: `29 December 2014` ; Format String: `dd-MM-yyyy (ww-YYYY)`; |
| 22 | + * | **Example 2:** Input Date: `29 December 2014` ; |
| 23 | + | Format String: `dd-MM-yyyy (ww-YYYY)`; |
18 | 24 | | Output string: `29-12-2014 (01-2015)` (This is correct) |
19 | 25 |
|
20 | 26 | #. F without ee/EE : Numeric day of week in a month without actual day. |
21 | 27 |
|
22 | 28 | * | **Example:** Input Date: `29 December 2014` ; Format String: `F-MM`; |
23 | | - | Output string: `5-12` (Wrong because it reads as *5th ___ of Dec* in English) |
| 29 | + | Output string: `5-12` (Wrong because it reads as *5th ___ of Dec* in |
| 30 | + | English) |
24 | 31 |
|
25 | 32 | #. F without MM : Numeric day of week in a month without month. |
26 | 33 |
|
27 | 34 | * | **Example:** Input Date: `29 December 2014` ; Format String: `F-EE` |
28 | | - | Output string: `5-Mon` (Wrong because it reads as *5th Mon of ___* in English) |
| 35 | + | Output string: `5-Mon` (Wrong because it reads as *5th Mon of ___* in |
| 36 | + | English) |
29 | 37 |
|
30 | 38 | #. WW without MM : Week of the month without the month. |
31 | 39 |
|
32 | 40 | * | **Example:** Input Date: `29 December 2014` ; Format String: `WW-yyyy` |
33 | | - | Output string: `05-2014` (Wrong because it reads as *5th Week of ___* in English) |
| 41 | + | Output string: `05-2014` (Wrong because it reads as *5th Week of ___* in |
| 42 | + | English) |
34 | 43 |
|
35 | | -#. YYYY + QQ : Week year specified with quarter of normal year (unless yyyy is also specified). |
| 44 | +#. YYYY + QQ : Week year specified with quarter of normal year |
| 45 | + (unless yyyy is also specified). |
36 | 46 |
|
37 | 47 | * | **Example 1:** Input Date: `29 December 2014` ; Format String: `YYYY-QQ` |
38 | | - | Output string: `2015-04` (Wrong because it’s not the 4th quarter of 2015) |
| 48 | + | Output string: `2015-04` (Wrong because it’s not the 4th quarter of |
| 49 | + | 2015) |
39 | 50 |
|
40 | | - * | **Example 2:** Input Date: `29 December 2014` ; Format String: `ww-YYYY (QQ-yyyy)` |
| 51 | + * | **Example 2:** Input Date: `29 December 2014` ; |
| 52 | + | Format String: `ww-YYYY (QQ-yyyy)` |
41 | 53 | | Output string: `01-2015 (04-2014)` (This is correct) |
42 | 54 |
|
43 | | -#. YYYY + MM : Week year specified with Month of a calendar year (unless yyyy is also specified). |
| 55 | +#. YYYY + MM : Week year specified with Month of a calendar year |
| 56 | + (unless yyyy is also specified). |
44 | 57 |
|
45 | 58 | * | **Example 1:** Input Date: `29 December 2014` ; Format String: `YYYY-MM` |
46 | 59 | | Output string: `2015-12` (Wrong because it’s not the 12th month of 2015) |
47 | 60 |
|
48 | | - * | **Example 2:** Input Date: `29 December 2014` ; Format String: `ww-YYYY (MM-yyyy)` |
| 61 | + * | **Example 2:** Input Date: `29 December 2014` ; |
| 62 | + | Format String: `ww-YYYY (MM-yyyy)` |
49 | 63 | | Output string: `01-2015 (12-2014)` (This is correct) |
50 | 64 |
|
51 | | -#. YYYY + DD : Week year with day of a calendar year (unless yyyy is also specified). |
| 65 | +#. YYYY + DD : Week year with day of a calendar year |
| 66 | + (unless yyyy is also specified). |
52 | 67 |
|
53 | 68 | * | **Example 1:** Input Date: `29 December 2014` ; Format String: `YYYY-DD` |
54 | 69 | | Output string: `2015-363` (Wrong because it’s not the 363rd day of 2015) |
55 | 70 |
|
56 | | - * | **Example 2:** Input Date: `29 December 2014` ; Format String: `ww-YYYY (DD-yyyy)` |
| 71 | + * | **Example 2:** Input Date: `29 December 2014` ; |
| 72 | + | Format String: `ww-YYYY (DD-yyyy)` |
57 | 73 | | Output string: `01-2015 (363-2014)` (This is correct) |
58 | 74 |
|
59 | | -#. YYYY + WW : Week year with week of a calendar year (unless yyyy is also specified). |
| 75 | +#. YYYY + WW : Week year with week of a calendar year |
| 76 | + (unless yyyy is also specified). |
60 | 77 |
|
61 | 78 | * | **Example 1:** Input Date: `29 December 2014` ; Format String: `YYYY-WW` |
62 | 79 | | Output string: `2015-05` (Wrong because it’s not the 5th week of 2015) |
63 | 80 |
|
64 | | - * | **Example 2:** Input Date: `29 December 2014` ; Format String: `ww-YYYY (WW-MM-yyyy)` |
| 81 | + * | **Example 2:** Input Date: `29 December 2014` ; |
| 82 | + | Format String: `ww-YYYY (WW-MM-yyyy)` |
65 | 83 | | Output string: `01-2015 (05-12-2014)` (This is correct) |
66 | 84 |
|
67 | | -#. YYYY + F : Week year with day of week in a calendar month (unless yyyy is also specified). |
| 85 | +#. YYYY + F : Week year with day of week in a calendar month |
| 86 | + (unless yyyy is also specified). |
68 | 87 |
|
69 | | - * | **Example 1:** Input Date: `29 December 2014` ; Format String: `YYYY-ww-F-EE` |
70 | | - | Output string: `2015-01-5-Mon` (Wrong because it’s not the 5th Monday of January in 2015) |
| 88 | + * | **Example 1:** Input Date: `29 December 2014` ; |
| 89 | + | Format String: `YYYY-ww-F-EE` |
| 90 | + | Output string: `2015-01-5-Mon` (Wrong because it’s not the 5th Monday of |
| 91 | + | January in 2015) |
71 | 92 |
|
72 | | - * | **Example 2:** Input Date: `29 December 2014` ; Format String: `ww-YYYY (F-EE-MM-yyyy)` |
| 93 | + * | **Example 2:** Input Date: `29 December 2014` ; |
| 94 | + | Format String: `ww-YYYY (F-EE-MM-yyyy)` |
73 | 95 | | Output string: `01-2015 (5-Mon-12-2014)` (This is correct) |
0 commit comments