feat: add some date settings

This commit is contained in:
David Ralph
2021-03-17 22:33:22 +00:00
parent 04fb389d59
commit b4a1a4bb19
3 changed files with 10 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ export default class TimeSettings extends React.PureComponent {
componentDidMount() {
document.getElementById('dateformat').value = localStorage.getItem('dateFormat');
document.getElementById('shortformat').value = localStorage.getItem('shortFormat');
document.getElementById('timeType').value = localStorage.getItem('timeType');
}
@@ -64,12 +65,18 @@ export default class TimeSettings extends React.PureComponent {
{digitalSettings}
<h3>{this.props.language.date.title}</h3>
<Checkbox name='date' text='Enabled' />
<Checkbox name='dayofweek' text={this.props.language.date.day_of_week} />
<Checkbox name='short' text={this.props.language.date.short_date} betaFeature={true} />
<Dropdown label={this.props.language.date.short_format} name='dateFormat' id='dateformat' onChange={() => localStorage.setItem('dateFormat', document.getElementById('dateformat').value)}>
<option className='choices' value='DMY'>DMY</option>
<option className='choices' value='MDY'>MDY</option>
<option className='choices' value='YMD'>YMD</option>
</Dropdown>
<Dropdown label={this.props.language.date.short_separator.title} name='shortFormat' id='shortformat' onChange={() => localStorage.setItem('shortFormat', document.getElementById('shortformat').value)}>
<option className='choices' value='default'>{this.props.language.date.short_separator.default}</option>
<option className='choices' value='dash'>{this.props.language.date.short_separator.dash}</option>
<option className='choices' value='gaps'>{this.props.language.date.short_separator.gaps}</option>
</Dropdown>
</div>
);
}

View File

@@ -56,8 +56,9 @@ export default class DateWidget extends React.PureComponent {
// Full date
const lang = localStorage.getItem('language');
const day = date.toLocaleDateString(lang, { weekday: 'long' });
const nth = (localStorage.getItem('datenth') === 'true') ? dtf.nth(date.getDate()) : date.getDate();
const day = (localStorage.getItem('dayofweek') === 'true') ? date.toLocaleDateString(lang, { weekday: 'long' }) : '';
const month = date.toLocaleDateString(lang, { month: 'long' });
const year = date.getFullYear();

View File

@@ -55,6 +55,7 @@
"percentage_complete": "Percentage of the Day Complete",
"date": {
"title": "Date",
"day_of_week": "Day of week",
"short_date": "Short Date",
"short_format": "Short Format",
"short_separator": {