Skip to content

Commit

Permalink
Added short month name function.
Browse files Browse the repository at this point in the history
  • Loading branch information
FlukeFan committed Jan 8, 2012
1 parent cfbf219 commit 1d98d25
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Source/OfflineExample/Scripts/Util/DateUtil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

(function () {
var shortMonth = new Array(12);
shortMonth[0] = "Jan";
shortMonth[1] = "Feb";
shortMonth[2] = "Mar";
shortMonth[3] = "Apr";
shortMonth[4] = "May";
shortMonth[5] = "Jun";
shortMonth[6] = "Jul";
shortMonth[7] = "Aug";
shortMonth[8] = "Sep";
shortMonth[9] = "Oct";
shortMonth[10] = "Nov";
shortMonth[11] = "Dec";

Date.prototype.getMonthShortName = function () {
return shortMonth[this.getMonth()];
}

})();
15 changes: 15 additions & 0 deletions Source/OfflineExample/Scripts/Util/spec/DateUtil.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

/// <reference path="..\..\..\..\..\SDKs\jasmine\jasmine.js"/>
/// <reference path="..\..\spec\GlobalStubs.js"/>
/// <reference path="..\DateUtil.js"/>

describe("DateUtil tests", function () {

it("should return the short month name for a date", function () {
var dte = new Date("01-Feb-2003");
var shortName = dte.getMonthShortName();

expect(shortName).toBe("Feb");
});

});
2 changes: 2 additions & 0 deletions Source/OfflineExample/Scripts/spec/LoadTests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ load("OfflineExample/Scripts/Offline/Dto/CmdFetchFuture.js");
load("OfflineExample/Scripts/Offline/OfflineGlobal.js");
load("OfflineExample/Scripts/Offline/StorageService.js");
load("OfflineExample/Scripts/Offline/Index.js");
load("OfflineExample/Scripts/Util/DateUtil.js");

load("OfflineExample/Scripts/Offline/spec/Index.spec.js");
load("OfflineExample/Scripts/Offline/spec/StorageService.spec.js");
load("OfflineExample/Scripts/Util/spec/DateUtil.spec.js");

0 comments on commit 1d98d25

Please sign in to comment.