Skip to content

Commit 5d2c6d5

Browse files
author
geoffreymcgill
committed
Updated @Version and release date to 2.2.1
Signed-off-by: geoffreymcgill <geoff@ext.net>
1 parent 7039e4f commit 5d2c6d5

22 files changed

Lines changed: 492 additions & 40 deletions
-52.1 KB
Binary file not shown.
55 KB
Binary file not shown.

Ext.Net.Utilities/Build/NuGet/Ext.NET.Utilities.README.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Project : Ext.NET.Utilties
2-
Version : 2.2.0
3-
Last Updated : 2013-03-20
2+
Version : 2.2.1
3+
Last Updated : 2013-04-16
44

55
--------------------------------------------------------------------------
6-
DESCRIPTION
6+
DESCRIPTION
77
--------------------------------------------------------------------------
88

99
A .NET Utility Class Library for Ext.NET (http://www.ext.net/)
@@ -14,8 +14,14 @@ Install using NuGet (http://nuget.org/packages/Ext.NET.Utilities).
1414

1515

1616
--------------------------------------------------------------------------
17-
RELEASE HISTORY
17+
RELEASE HISTORY
1818
--------------------------------------------------------------------------
19+
20+
2013-04-16 (geoffreymcgill)
21+
22+
- Release v2.2.1
23+
24+
1925
2013-03-20 (geoffreymcgill)
2026

2127
- Release v2.2.0
Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
/*
2+
* @version : 2.2.1
3+
* @author : Ext.NET, Inc. http://www.ext.net/
4+
* @date : 2013-04-16
5+
* @copyright : Copyright (c) 2007-2013, Ext.NET, Inc. (http://www.ext.net/). All rights reserved.
6+
* @license : See license.txt and http://www.ext.net/license/.
7+
* @website : http://www.ext.net/
8+
*/
9+
10+
using System;
11+
using System.Globalization;
12+
using System.Text;
13+
using System.Text.RegularExpressions;
14+
using System.Web;
15+
16+
namespace Ext.Net.Utilities
17+
{
18+
/// <summary>
19+
///
20+
/// </summary>
21+
public static class DateTimeUtils
22+
{
23+
/// <summary>
24+
/// Returns an ISO 8601 formatted DateTime string
25+
/// </summary>
26+
/// <param name="instance">The DateTime object to format</param>
27+
/// <returns>The ISO 8601 formatted string</returns>
28+
public static string ToISOString(this DateTime instance)
29+
{
30+
return instance.ToString("yyyy-MM-ddTHH:mm:ss");
31+
}
32+
33+
/// <summary>
34+
/// Returns the Date portion only of an ISO 8601 formatted DateTime string
35+
/// </summary>
36+
/// <param name="instance">The DateTime object to format</param>
37+
/// <returns>The ISO 8601 formatted string</returns>
38+
public static string ToISODateString(this DateTime instance)
39+
{
40+
return instance.ToString("yyyy-MM-dd");
41+
}
42+
43+
/// <summary>
44+
/// Returns the Time portion only of an ISO 8601 formatted DateTime string
45+
/// </summary>
46+
/// <param name="instance">The DateTime object to format</param>
47+
/// <returns>The ISO 8601 formatted string</returns>
48+
public static string ToISOTimeString(this DateTime instance)
49+
{
50+
return instance.ToString("HH:mm:ss");
51+
}
52+
53+
/// <summary>
54+
/// Accepts a Unix/PHP date string format and returns a valid .NET date format
55+
/// </summary>
56+
/// <param name="format">The PHP format string</param>
57+
/// <returns>The format string converted to .NET DateTime format specifiers</returns>
58+
public static string ConvertPHPToNet(string format)
59+
{
60+
if (string.IsNullOrEmpty(format))
61+
{
62+
return "";
63+
}
64+
65+
StringBuilder final = new StringBuilder(128);
66+
string temp = "";
67+
Match m = Regex.Match(format, @"(%|\\)?.|%%", RegexOptions.IgnoreCase);
68+
69+
while(m.Success)
70+
{
71+
temp = m.Value;
72+
73+
if (temp.StartsWith(@"\") || temp.StartsWith("%%"))
74+
{
75+
final.Append(temp.Replace(@"\", "").Replace("%%", "%"));
76+
}
77+
78+
switch(temp)
79+
{
80+
case "d":
81+
final.Append("dd");
82+
break;
83+
case "D":
84+
final.Append("ddd");
85+
break;
86+
case "j":
87+
final.Append("d");
88+
break;
89+
case "l":
90+
final.Append("dddd");
91+
break;
92+
case "F":
93+
final.Append("MMMM");
94+
break;
95+
case "m":
96+
final.Append("MM");
97+
break;
98+
case "M":
99+
final.Append("MMM");
100+
break;
101+
case "n":
102+
final.Append("M");
103+
break;
104+
case "Y":
105+
final.Append("yyyy");
106+
break;
107+
case "y":
108+
final.Append("yy");
109+
break;
110+
case "a":
111+
case "A":
112+
final.Append("tt");
113+
break;
114+
case "g":
115+
final.Append("h");
116+
break;
117+
case "G":
118+
final.Append("H");
119+
break;
120+
case "h":
121+
final.Append("hh");
122+
break;
123+
case "H":
124+
final.Append("HH");
125+
break;
126+
case "i":
127+
final.Append("mm");
128+
break;
129+
case "s":
130+
final.Append("ss");
131+
break;
132+
default:
133+
final.Append(temp);
134+
break;
135+
}
136+
m = m.NextMatch();
137+
}
138+
139+
return final.ToString();
140+
}
141+
142+
/// <summary>
143+
///
144+
/// </summary>
145+
/// <param name="format"></param>
146+
/// <returns></returns>
147+
public static string ConvertNetToPHP(string format)
148+
{
149+
return DateTimeUtils.ConvertNetToPHP(format, CultureInfo.CurrentUICulture);
150+
}
151+
152+
/// <summary>
153+
/// Accepts a Unix/PHP date string format and returns a valid .NET date format
154+
/// </summary>
155+
/// <param name="format">The .NET format string</param>
156+
/// <param name="culture"></param>
157+
/// <returns>The format string converted to PHP format specifiers</returns>
158+
public static string ConvertNetToPHP(string format, CultureInfo culture)
159+
{
160+
if (string.IsNullOrEmpty(format))
161+
{
162+
return "";
163+
}
164+
165+
StringBuilder final = new StringBuilder(128);
166+
string temp = "";
167+
168+
switch (format.Trim())
169+
{
170+
case "d":
171+
format = culture.DateTimeFormat.ShortDatePattern;
172+
break;
173+
case "D":
174+
format = culture.DateTimeFormat.LongDatePattern;
175+
break;
176+
case "t":
177+
format = culture.DateTimeFormat.ShortTimePattern;
178+
break;
179+
case "T":
180+
format = culture.DateTimeFormat.LongTimePattern;
181+
break;
182+
}
183+
184+
Match m = Regex.Match(format, @"(\\)?(dd?d?d?|M\$|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|S)|.", RegexOptions.IgnoreCase);
185+
186+
while (m.Success)
187+
{
188+
temp = m.Value;
189+
190+
switch (temp)
191+
{
192+
case "dd":
193+
final.Append("d");
194+
break;
195+
case "ddd":
196+
final.Append("D");
197+
break;
198+
case "d":
199+
final.Append("j");
200+
break;
201+
case "dddd":
202+
final.Append("l");
203+
break;
204+
case "M$":
205+
final.Append("MS");
206+
break;
207+
case "MMMM":
208+
final.Append("F");
209+
break;
210+
case "MM":
211+
final.Append("m");
212+
break;
213+
case "MMM":
214+
final.Append("M");
215+
break;
216+
case "M":
217+
final.Append("n");
218+
break;
219+
case "yyyy":
220+
final.Append("Y");
221+
break;
222+
case "yy":
223+
final.Append("y");
224+
break;
225+
case "tt":
226+
final.Append("a");
227+
break;
228+
case "h":
229+
final.Append("g");
230+
break;
231+
case "H":
232+
final.Append("G");
233+
break;
234+
case "hh":
235+
final.Append("h");
236+
break;
237+
case "HH":
238+
final.Append("H");
239+
break;
240+
case "mm":
241+
final.Append("i");
242+
break;
243+
case "ss":
244+
final.Append("s");
245+
break;
246+
default:
247+
final.Append(temp);
248+
break;
249+
}
250+
m = m.NextMatch();
251+
}
252+
253+
return final.ToString();
254+
}
255+
256+
/// <summary>
257+
/// Convert .NET DateTime to JavaScript object
258+
/// </summary>
259+
/// <param name="date">.NET DateTime</param>
260+
/// <returns>JavaScript Date as string</returns>
261+
public static string DateNetToJs(DateTime date)
262+
{
263+
DateTimeOffset value = new DateTimeOffset(date);
264+
DateTimeOffset utcDateTime = value.ToUniversalTime();
265+
long javaScriptTicks = (utcDateTime.Ticks - (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).Ticks) / (long)10000;
266+
267+
string offset;
268+
TimeSpan utcOffset = value.Offset;
269+
offset = utcOffset.Hours.ToString("+00;-00", CultureInfo.InvariantCulture) + utcOffset.Minutes.ToString("00;00", CultureInfo.InvariantCulture);
270+
271+
return string.Concat("new Date(", javaScriptTicks.ToString(CultureInfo.InvariantCulture), offset, ")");
272+
}
273+
274+
/// <summary>
275+
///
276+
/// </summary>
277+
/// <returns></returns>
278+
public static DateTimeFormatInfo ClientDateTimeFormatInfo()
279+
{
280+
try
281+
{
282+
if (HttpContext.Current == null || HttpContext.Current.Request.UserLanguages == null || HttpContext.Current.Request.UserLanguages.Length == 0)
283+
{
284+
return CultureInfo.InvariantCulture.DateTimeFormat;
285+
}
286+
287+
return CultureInfo.CreateSpecificCulture(HttpContext.Current.Request.UserLanguages[0]).DateTimeFormat;
288+
}
289+
catch
290+
{
291+
return CultureInfo.InvariantCulture.DateTimeFormat;
292+
}
293+
}
294+
}
295+
}

Ext.Net.Utilities/Enumerable/EnumerableUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* @version : 2.2.0
2+
* @version : 2.2.1
33
* @author : Ext.NET, Inc. http://www.ext.net/
4-
* @date : 2013-03-20
4+
* @date : 2013-04-16
55
* @copyright : Copyright (c) 2007-2013, Ext.NET, Inc. (http://www.ext.net/). All rights reserved.
66
* @license : See license.txt and http://www.ext.net/license/.
77
* @website : http://www.ext.net/

Ext.Net.Utilities/Html/HtmlUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* @version : 2.2.0
2+
* @version : 2.2.1
33
* @author : Ext.NET, Inc. http://www.ext.net/
4-
* @date : 2013-03-20
4+
* @date : 2013-04-16
55
* @copyright : Copyright (c) 2007-2013, Ext.NET, Inc. (http://www.ext.net/). All rights reserved.
66
* @license : See license.txt and http://www.ext.net/license/.
77
* @website : http://www.ext.net/

Ext.Net.Utilities/IO/FileUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* @version : 2.2.0
2+
* @version : 2.2.1
33
* @author : Ext.NET, Inc. http://www.ext.net/
4-
* @date : 2013-03-20
4+
* @date : 2013-04-16
55
* @copyright : Copyright (c) 2007-2013, Ext.NET, Inc. (http://www.ext.net/). All rights reserved.
66
* @license : See license.txt and http://www.ext.net/license/.
77
* @website : http://www.ext.net/

Ext.Net.Utilities/Inflatr/Base.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* @version : 2.2.0
2+
* @version : 2.2.1
33
* @author : Ext.NET, Inc. http://www.ext.net/
4-
* @date : 2013-03-20
4+
* @date : 2013-04-16
55
* @copyright : Copyright (c) 2007-2013, Ext.NET, Inc. (http://www.ext.net/). All rights reserved.
66
* @license : See license.txt and http://www.ext.net/license/.
77
* @website : http://www.ext.net/

Ext.Net.Utilities/Inflatr/Javascript.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* @version : 2.2.0
2+
* @version : 2.2.1
33
* @author : Ext.NET, Inc. http://www.ext.net/
4-
* @date : 2013-03-20
4+
* @date : 2013-04-16
55
* @copyright : Copyright (c) 2007-2013, Ext.NET, Inc. (http://www.ext.net/). All rights reserved.
66
* @license : See license.txt and http://www.ext.net/license/.
77
* @website : http://www.ext.net/

Ext.Net.Utilities/Inflatr/Options.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* @version : 2.2.0
2+
* @version : 2.2.1
33
* @author : Ext.NET, Inc. http://www.ext.net/
4-
* @date : 2013-03-20
4+
* @date : 2013-04-16
55
* @copyright : Copyright (c) 2007-2013, Ext.NET, Inc. (http://www.ext.net/). All rights reserved.
66
* @license : See license.txt and http://www.ext.net/license/.
77
* @website : http://www.ext.net/

0 commit comments

Comments
 (0)