Make it possible to choose between MM/dd and dd/MM date format

This commit is contained in:
Verabird 2014-12-24 22:18:50 -05:00
parent e391fc04f0
commit 7297429888
6 changed files with 20 additions and 5 deletions

View file

@ -65,6 +65,13 @@ habitrpg.controller('SettingsCtrl',
User.set({'preferences.language': $scope.language.code});
}
$scope.availableFormats = ['MM/dd/yyyy','dd/MM/yyyy','yyyy/MM/dd'];
$scope.changeDateFormat = function(){
var dateFormat= User.user.preferences.dateFormat;
User.set({'preferences.dateFormat': dateFormat});
}
$scope.reroll = function(){
User.user.ops.reroll({});
$rootScope.$state.go('tasks');

View file

@ -278,6 +278,7 @@ var UserSchema = new Schema({
automaticAllocation: Boolean,
allocationMode: {type:String, enum: ['flat','classbased','taskbased'], 'default': 'flat'},
costume: Boolean,
dateFormat: {type: String, enum:['MM/dd/yyyy', 'dd/MM/yyyy', 'yyyy/MM/dd'], 'default': 'MM/dd/yyyy'},
sleep: {type: Boolean, 'default': false},
stickyHeader: {type: Boolean, 'default': true},
disableClasses: {type: Boolean, 'default': false},

View file

@ -36,6 +36,12 @@ script(type='text/ng-template', id='partials/options.settings.settings.html')
br
strong
!=env.t('helpWithTranslation')
.form-horizontal
h5=env.t('dateFormat')
select.form-control(ng-model='user.preferences.dateFormat', ng-options='DF for DF in availableFormats', ng-change='changeDateFormat()')
.checkbox
label
input(type='checkbox', ng-click='hideHeader() ', ng-checked='user.preferences.hideHeader!==true')

View file

@ -14,7 +14,7 @@ mixin chatMessages(inbox)
// this invisible username label is here to push the message text far enough right that the visible label can be floated to this point without covering up any of the text
markdown(ng-model='::message.text')
| -
span.muted.time(from-now='::message.timestamp' tooltip="{{::message.timestamp | date:'short'}}")
span.muted.time(from-now='::message.timestamp' tooltip="{{::message.timestamp | date:user.preferences.dateFormat.concat(' HH:mm:ss')}}")
unless inbox
span
a.label.label-default(ng-show='countExists(message.likes)', ng-class='{"label-success":message.likes[user._id]}', ng-click='likeChatMessage(group,message)') +{{countExists(message.likes)}}

View file

@ -15,12 +15,12 @@ script(type='text/ng-template', id='modals/member.html')
| 
=env.t('memberSince')
| 
| {{::profile.auth.timestamps.created | date:env.t('mediumdate')}} -
| {{::profile.auth.timestamps.created | date:user.preferences.dateFormat}} -
li(ng-show='::profile.auth.timestamps.loggedin')
| 
=env.t('lastLoggedIn')
| 
| {{::profile.auth.timestamps.loggedin | date:env.t('mediumdate')}} -
| {{::profile.auth.timestamps.loggedin | date:user.preferences.dateFormat}} -
h3=env.t('stats')
.label.label-info {{:: {warrior:env.t("warrior"), wizard:env.t("mage"), rogue:env.t("rogue"), healer:env.t("healer")}[profile.stats.class] }}
include ../profiles/stats

View file

@ -4,7 +4,8 @@ li(bindonce='list', id='task-{{::task.id}}', ng-repeat='task in obj[list.type+"s
// Due Date
span(ng-if='task.type=="todo" && task.date')
span(ng-class='{"label label-danger":(moment(task.date).isBefore(_today, "days") && !task.completed)}') {{moment(task.date).format(env.t('shortdate'))}}
span(ng-class='{"label label-danger":(moment(task.date).isBefore(_today, "days") && !task.completed)}') {{task.date | date:user.preferences.dateFormat.substr(0,5)}}
//{{::profile.auth.timestamps.created | date:user.preferences.dateFormat}}
// Streak
|  
span(ng-show='task.streak') {{task.streak}} 
@ -190,7 +191,7 @@ li(bindonce='list', id='task-{{::task.id}}', ng-repeat='task in obj[list.type+"s
// if Todos, the due date
fieldset.option-group(ng-if='task.type=="todo" && !task.challenge.id')
legend.option-title=env.t('dueDate')
input.option-content.datepicker(type='text', datepicker-popup=env.t('mediumdate'), ng-model='task.date', is-open='datepickerOpened', ng-click='datepickerOpened = true')
input.option-content.datepicker(type='text', datepicker-popup='{{user.preferences.dateFormat}}', ng-model='task.date', is-open='datepickerOpened', ng-click='datepickerOpened = true')
// Tags
fieldset.option-group(ng-if='!$state.includes("options.social.challenges")')