Revize c4383c00
Přidáno uživatelem Eliška Mourycová před více než 3 roky(ů)
Server/ServerApp/DataDownload/Date.cs | ||
---|---|---|
38 | 38 |
return new Date(newMonth, newYear); |
39 | 39 |
} |
40 | 40 |
|
41 |
/// <summary> |
|
42 |
/// Parses the date given in format: 1-2020 |
|
43 |
/// </summary> |
|
44 |
/// <param name="str">The string to parse</param> |
|
45 |
/// <returns>A new date</returns> |
|
46 |
public static Date ParseDate(string str) |
|
47 |
{ |
|
48 |
|
|
49 |
uint month, year; |
|
50 |
|
|
51 |
string ds = str.Trim(); |
|
52 |
string[] splits = ds.Split('-'); |
|
53 |
|
|
54 |
if(splits.Length != 2) |
|
55 |
{ |
|
56 |
Console.WriteLine("Unknown date format. Must be e.g. 1-2020."); |
|
57 |
return null; |
|
58 |
} |
|
59 |
|
|
60 |
bool monthOk = uint.TryParse(splits[0], out month); |
|
61 |
bool yearOk = uint.TryParse(splits[1], out year); |
|
62 |
|
|
63 |
if(!monthOk || !yearOk) |
|
64 |
{ |
|
65 |
Console.WriteLine("Unknown date format. Must be e.g. 1-2020."); |
|
66 |
return null; |
|
67 |
} |
|
68 |
|
|
69 |
|
|
70 |
try |
|
71 |
{ |
|
72 |
Date d = new Date(month, year); |
|
73 |
return d; |
|
74 |
} |
|
75 |
catch (Exception ex) |
|
76 |
{ |
|
77 |
return null; |
|
78 |
} |
|
79 |
|
|
80 |
|
|
81 |
return null; |
|
82 |
} |
|
83 |
|
|
41 | 84 |
|
42 | 85 |
#region OVERRIDEN METHODS FOR OF THE OBJECT CLASS |
43 | 86 |
public override bool Equals(object obj) |
Také k dispozici: Unified diff
Re #8942. Started implementing admin commands.