datejs-rails 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -21,3 +21,9 @@ This will require the en-US version of datejs. All other localizations are
21
21
  available as well. For instance, you could instead:
22
22
 
23
23
  //= require date-fr-FR
24
+
25
+ Optionally, require `extras.js` for `strftime`-style [FormatSpecifiers](http://code.google.com/p/datejs/wiki/FormatSpecifiers).
26
+
27
+ //= require datejs-extras
28
+
29
+
@@ -0,0 +1,8 @@
1
+ ### Version 1.1.0 (2012-01-11)
2
+ * Added ability to use strftime-like formatters by including extras.js from datejs SVN repository.
3
+
4
+ ### Version 1.0.1
5
+ * Fixed gemspec to rely on Railties rather than Rails directly.
6
+
7
+ ### Version 1.0.0
8
+ * Initial Release
@@ -0,0 +1,332 @@
1
+ /**
2
+ * @version: 1.0 Alpha-1
3
+ * @author: Coolite Inc. http://www.coolite.com/
4
+ * @date: 2008-04-13
5
+ * @copyright: Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). All rights reserved.
6
+ * @license: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/.
7
+ * @website: http://www.datejs.com/
8
+ */
9
+
10
+ (function () {
11
+ var $D = Date,
12
+ $P = $D.prototype,
13
+ $C = $D.CultureInfo,
14
+ $f = [],
15
+ p = function (s, l) {
16
+ if (!l) {
17
+ l = 2;
18
+ }
19
+ return ("000" + s).slice(l * -1);
20
+ };
21
+
22
+ /**
23
+ * Converts a PHP format string to Java/.NET format string.
24
+ * A PHP format string can be used with .$format or .format.
25
+ * A Java/.NET format string can be used with .toString().
26
+ * The .parseExact function will only accept a Java/.NET format string
27
+ *
28
+ * Example
29
+ <pre>
30
+ var f1 = "%m/%d/%y"
31
+ var f2 = Date.normalizeFormat(f1); // "MM/dd/yy"
32
+
33
+ new Date().format(f1); // "04/13/08"
34
+ new Date().$format(f1); // "04/13/08"
35
+ new Date().toString(f2); // "04/13/08"
36
+
37
+ var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008
38
+ </pre>
39
+ * @param {String} A PHP format string consisting of one or more format spcifiers.
40
+ * @return {String} The PHP format converted to a Java/.NET format string.
41
+ */
42
+ $D.normalizeFormat = function (format) {
43
+ $f = [];
44
+ var t = new Date().$format(format);
45
+ return $f.join("");
46
+ };
47
+
48
+ /**
49
+ * Format a local Unix timestamp according to locale settings
50
+ *
51
+ * Example
52
+ <pre>
53
+ Date.strftime("%m/%d/%y", new Date()); // "04/13/08"
54
+ Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08"
55
+ </pre>
56
+ * @param {String} A format string consisting of one or more format spcifiers [Optional].
57
+ * @param {Number} The number representing the number of seconds that have elapsed since January 1, 1970 (local time).
58
+ * @return {String} A string representation of the current Date object.
59
+ */
60
+ $D.strftime = function (format, time) {
61
+ return new Date(time * 1000).$format(format);
62
+ };
63
+
64
+ /**
65
+ * Parse any textual datetime description into a Unix timestamp.
66
+ * A Unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT).
67
+ *
68
+ * Example
69
+ <pre>
70
+ Date.strtotime("04/13/08"); // 1208044800
71
+ Date.strtotime("1970-01-01T00:00:00Z"); // 0
72
+ </pre>
73
+ * @param {String} A format string consisting of one or more format spcifiers [Optional].
74
+ * @param {Object} A string or date object.
75
+ * @return {String} A string representation of the current Date object.
76
+ */
77
+ $D.strtotime = function (time) {
78
+ var d = $D.parse(time);
79
+ d.addMinutes(d.getTimezoneOffset() * -1);
80
+ return Math.round($D.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()) / 1000);
81
+ };
82
+
83
+ /**
84
+ * Converts the value of the current Date object to its equivalent string representation using a PHP/Unix style of date format specifiers.
85
+ *
86
+ * The following descriptions are from http://www.php.net/strftime and http://www.php.net/manual/en/function.date.php.
87
+ * Copyright (c) 2001-2008 The PHP Group
88
+ *
89
+ * Format Specifiers
90
+ <pre>
91
+ Format Description Example
92
+ ------ --------------------------------------------------------------------------- -----------------------
93
+ %a abbreviated weekday name according to the current localed "Mon" through "Sun"
94
+ %A full weekday name according to the current locale "Sunday" through "Saturday"
95
+ %b abbreviated month name according to the current locale "Jan" through "Dec"
96
+ %B full month name according to the current locale "January" through "December"
97
+ %c preferred date and time representation for the current locale "4/13/2008 12:33 PM"
98
+ %C century number (the year divided by 100 and truncated to an integer) "00" to "99"
99
+ %d day of the month as a decimal number "01" to "31"
100
+ %D same as %m/%d/%y "04/13/08"
101
+ %e day of the month as a decimal number, a single digit is preceded by a space "1" to "31"
102
+ %g like %G, but without the century "08"
103
+ %G The 4-digit year corresponding to the ISO week number (see %V). "2008"
104
+ This has the same format and value as %Y, except that if the ISO week number
105
+ belongs to the previous or next year, that year is used instead.
106
+ %h same as %b "Jan" through "Dec"
107
+ %H hour as a decimal number using a 24-hour clock "00" to "23"
108
+ %I hour as a decimal number using a 12-hour clock "01" to "12"
109
+ %j day of the year as a decimal number "001" to "366"
110
+ %m month as a decimal number "01" to "12"
111
+ %M minute as a decimal number "00" to "59"
112
+ %n newline character "\n"
113
+ %p either "am" or "pm" according to the given time value, or the "am" or "pm"
114
+ corresponding strings for the current locale
115
+ %r time in a.m. and p.m. notation "8:44 PM"
116
+ %R time in 24 hour notation "20:44"
117
+ %S second as a decimal number "00" to "59"
118
+ %t tab character "\t"
119
+ %T current time, equal to %H:%M:%S "12:49:11"
120
+ %u weekday as a decimal number ["1", "7"], with "1" representing Monday "1" to "7"
121
+ %U week number of the current year as a decimal number, starting with the "0" to ("52" or "53")
122
+ first Sunday as the first day of the first week
123
+ %V The ISO 8601:1988 week number of the current year as a decimal number, "00" to ("52" or "53")
124
+ range 01 to 53, where week 1 is the first week that has at least 4 days
125
+ in the current year, and with Monday as the first day of the week.
126
+ (Use %G or %g for the year component that corresponds to the week number
127
+ for the specified timestamp.)
128
+ %W week number of the current year as a decimal number, starting with the "00" to ("52" or "53")
129
+ first Monday as the first day of the first week
130
+ %w day of the week as a decimal, Sunday being "0" "0" to "6"
131
+ %x preferred date representation for the current locale without the time "4/13/2008"
132
+ %X preferred time representation for the current locale without the date "12:53:05"
133
+ %y year as a decimal number without a century "00" "99"
134
+ %Y year as a decimal number including the century "2008"
135
+ %Z time zone or name or abbreviation "UTC", "EST", "PST"
136
+ %z same as %Z
137
+ %% a literal "%" character "%"
138
+
139
+ d Day of the month, 2 digits with leading zeros "01" to "31"
140
+ D A textual representation of a day, three letters "Mon" through "Sun"
141
+ j Day of the month without leading zeros "1" to "31"
142
+ l A full textual representation of the day of the week (lowercase "L") "Sunday" through "Saturday"
143
+ N ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) "1" (for Monday) through "7" (for Sunday)
144
+ S English ordinal suffix for the day of the month, 2 characters "st", "nd", "rd" or "th". Works well with j
145
+ w Numeric representation of the day of the week "0" (for Sunday) through "6" (for Saturday)
146
+ z The day of the year (starting from "0") "0" through "365"
147
+ W ISO-8601 week number of year, weeks starting on Monday "00" to ("52" or "53")
148
+ F A full textual representation of a month, such as January or March "January" through "December"
149
+ m Numeric representation of a month, with leading zeros "01" through "12"
150
+ M A short textual representation of a month, three letters "Jan" through "Dec"
151
+ n Numeric representation of a month, without leading zeros "1" through "12"
152
+ t Number of days in the given month "28" through "31"
153
+ L Whether it's a leap year "1" if it is a leap year, "0" otherwise
154
+ o ISO-8601 year number. This has the same value as Y, except that if the "2008"
155
+ ISO week number (W) belongs to the previous or next year, that year
156
+ is used instead.
157
+ Y A full numeric representation of a year, 4 digits "2008"
158
+ y A two digit representation of a year "08"
159
+ a Lowercase Ante meridiem and Post meridiem "am" or "pm"
160
+ A Uppercase Ante meridiem and Post meridiem "AM" or "PM"
161
+ B Swatch Internet time "000" through "999"
162
+ g 12-hour format of an hour without leading zeros "1" through "12"
163
+ G 24-hour format of an hour without leading zeros "0" through "23"
164
+ h 12-hour format of an hour with leading zeros "01" through "12"
165
+ H 24-hour format of an hour with leading zeros "00" through "23"
166
+ i Minutes with leading zeros "00" to "59"
167
+ s Seconds, with leading zeros "00" through "59"
168
+ u Milliseconds "54321"
169
+ e Timezone identifier "UTC", "EST", "PST"
170
+ I Whether or not the date is in daylight saving time (uppercase i) "1" if Daylight Saving Time, "0" otherwise
171
+ O Difference to Greenwich time (GMT) in hours "+0200", "-0600"
172
+ P Difference to Greenwich time (GMT) with colon between hours and minutes "+02:00", "-06:00"
173
+ T Timezone abbreviation "UTC", "EST", "PST"
174
+ Z Timezone offset in seconds. The offset for timezones west of UTC is "-43200" through "50400"
175
+ always negative, and for those east of UTC is always positive.
176
+ c ISO 8601 date "2004-02-12T15:19:21+00:00"
177
+ r RFC 2822 formatted date "Thu, 21 Dec 2000 16:01:07 +0200"
178
+ U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) "0"
179
+ </pre>
180
+ * @param {String} A format string consisting of one or more format spcifiers [Optional].
181
+ * @return {String} A string representation of the current Date object.
182
+ */
183
+ $P.$format = function (format) {
184
+ var x = this,
185
+ y,
186
+ t = function (v) {
187
+ $f.push(v);
188
+ return x.toString(v);
189
+ };
190
+
191
+ return format ? format.replace(/(%|\\)?.|%%/g,
192
+ function (m) {
193
+ if (m.charAt(0) === "\\" || m.substring(0, 2) === "%%") {
194
+ return m.replace("\\", "").replace("%%", "%");
195
+ }
196
+ switch (m) {
197
+ case "d":
198
+ case "%d":
199
+ return t("dd");
200
+ case "D":
201
+ case "%a":
202
+ return t("ddd");
203
+ case "j":
204
+ case "%e":
205
+ return t("d");
206
+ case "l":
207
+ case "%A":
208
+ return t("dddd");
209
+ case "N":
210
+ case "%u":
211
+ return x.getDay() + 1;
212
+ case "S":
213
+ return t("S");
214
+ case "w":
215
+ case "%w":
216
+ return x.getDay();
217
+ case "z":
218
+ return x.getOrdinalNumber();
219
+ case "%j":
220
+ return p(x.getOrdinalNumber(), 3);
221
+ case "%U":
222
+ var d1 = x.clone().set({month: 0, day: 1}).addDays(-1).moveToDayOfWeek(0),
223
+ d2 = x.clone().addDays(1).moveToDayOfWeek(0, -1);
224
+ return (d2 < d1) ? "00" : p((d2.getOrdinalNumber() - d1.getOrdinalNumber()) / 7 + 1);
225
+ case "W":
226
+ case "%V":
227
+ return x.getISOWeek();
228
+ case "%W":
229
+ return p(x.getWeek());
230
+ case "F":
231
+ case "%B":
232
+ return t("MMMM");
233
+ case "m":
234
+ case "%m":
235
+ return t("MM");
236
+ case "M":
237
+ case "%b":
238
+ case "%h":
239
+ return t("MMM");
240
+ case "n":
241
+ return t("M");
242
+ case "t":
243
+ return $D.getDaysInMonth(x.getFullYear(), x.getMonth());
244
+ case "L":
245
+ return ($D.isLeapYear(x.getFullYear())) ? 1 : 0;
246
+ case "o":
247
+ case "%G":
248
+ return x.setWeek(x.getISOWeek()).toString("yyyy");
249
+ case "%g":
250
+ return x.$format("%G").slice(-2);
251
+ case "Y":
252
+ case "%Y":
253
+ return t("yyyy");
254
+ case "y":
255
+ case "%y":
256
+ return t("yy");
257
+ case "a":
258
+ case "%p":
259
+ return t("tt").toLowerCase();
260
+ case "A":
261
+ return t("tt").toUpperCase();
262
+ case "g":
263
+ case "%I":
264
+ return t("h");
265
+ case "G":
266
+ return t("H");
267
+ case "h":
268
+ return t("hh");
269
+ case "H":
270
+ case "%H":
271
+ return t("HH");
272
+ case "i":
273
+ case "%M":
274
+ return t("mm");
275
+ case "s":
276
+ case "%S":
277
+ return t("ss");
278
+ case "u":
279
+ return p(x.getMilliseconds(), 3);
280
+ case "I":
281
+ return (x.isDaylightSavingTime()) ? 1 : 0;
282
+ case "O":
283
+ return x.getUTCOffset();
284
+ case "P":
285
+ y = x.getUTCOffset();
286
+ return y.substring(0, y.length - 2) + ":" + y.substring(y.length - 2);
287
+ case "e":
288
+ case "T":
289
+ case "%z":
290
+ case "%Z":
291
+ return x.getTimezone();
292
+ case "Z":
293
+ return x.getTimezoneOffset() * -60;
294
+ case "B":
295
+ var now = new Date();
296
+ return Math.floor(((now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + (now.getTimezoneOffset() + 60) * 60) / 86.4);
297
+ case "c":
298
+ return x.toISOString().replace(/\"/g, "");
299
+ case "U":
300
+ return $D.strtotime("now");
301
+ case "%c":
302
+ return t("d") + " " + t("t");
303
+ case "%C":
304
+ return Math.floor(x.getFullYear() / 100 + 1);
305
+ case "%D":
306
+ return t("MM/dd/yy");
307
+ case "%n":
308
+ return "\\n";
309
+ case "%t":
310
+ return "\\t";
311
+ case "%r":
312
+ return t("hh:mm tt");
313
+ case "%R":
314
+ return t("H:mm");
315
+ case "%T":
316
+ return t("H:mm:ss");
317
+ case "%x":
318
+ return t("d");
319
+ case "%X":
320
+ return t("t");
321
+ default:
322
+ $f.push(m);
323
+ return m;
324
+ }
325
+ }
326
+ ) : this._toString();
327
+ };
328
+
329
+ if (!$P.format) {
330
+ $P.format = $P.$format;
331
+ }
332
+ }());
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datejs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-28 00:00:00.000000000 Z
12
+ date: 2012-01-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &2152404920 !ruby/object:Gem::Requirement
16
+ requirement: &2152495020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152404920
24
+ version_requirements: *2152495020
25
25
  description:
26
26
  email:
27
27
  executables: []
@@ -187,6 +187,8 @@ files:
187
187
  - vendor/assets/javascripts/date-zh-TW.js
188
188
  - vendor/assets/javascripts/date-zu-ZA.js
189
189
  - vendor/assets/javascripts/date.js
190
+ - vendor/assets/javascripts/datejs-extras.js
191
+ - changelog.md
190
192
  - MIT-LICENSE
191
193
  - README.md
192
194
  homepage: https://github.com/derekprior/datejs-rails