forked from jhipster/generator-jhipster
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the date transformations to a service
- Loading branch information
Showing
3 changed files
with
36 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
app/templates/src/main/webapp/scripts/components/util/_dateutil.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
angular.module('<%=angularAppName%>') | ||
.service('DateUtils', function () { | ||
this.convertLocaleDateToServer = function(date) { | ||
if (date) { | ||
var utcDate = new Date(); | ||
utcDate.setUTCDate(date.getDate()); | ||
utcDate.setUTCMonth(date.getMonth()); | ||
utcDate.setUTCFullYear(date.getFullYear()); | ||
return utcDate; | ||
} else { | ||
return null; | ||
} | ||
}; | ||
this.convertLocaleDateFromServer = function(date) { | ||
if (date) { | ||
var dateString = date.split("-"); | ||
return new Date(dateString[0], dateString[1] - 1, dateString[2]); | ||
} | ||
return null; | ||
}; | ||
this.convertDateTimeFromServer = function(date) { | ||
if (date) { | ||
return new Date(date); | ||
} else { | ||
return null; | ||
} | ||
} | ||
}); |
21 changes: 5 additions & 16 deletions
21
entity/templates/src/main/webapp/components/_entity-service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3d78486
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the js file is not injected into index html causing issue jhipster#1549