diff options
Diffstat (limited to 'front/config.jsx')
-rw-r--r-- | front/config.jsx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/front/config.jsx b/front/config.jsx new file mode 100644 index 0000000..51373cc --- /dev/null +++ b/front/config.jsx @@ -0,0 +1,49 @@ +import "preact/debug"; +import { Component, Fragment, h } from 'preact'; +import strftime from 'strftime'; +/** @jsx h */ +/** @jsxFrag Fragment */ + +export class Config { + static getBrowserTimezoneOffset() { + return - new Date().getTimezoneOffset(); + } + + getDateFormatter() { + let strftime_with_offset = strftime.timezone(this.timezoneOffset); + if (this.time.locale != null) { + return strftime_with_offset.localizeByIdentifier(props.locale); + } else { + this.state = { formatTime: strftime_with_offset } + } + } + + constructor() { + this.time = { + locale: null, + timezoneOffset: this.constructor.getBrowserTimezoneOffset(), + defaultDate: { + type: "current", + format: "%Y-%m-%d %H:%M" + }, + } + } + + getDefaultDate() { + if (this.time.defaultDate.type == "current") + return strftime(this.time.defaultDate.format, new Date()) + else + return "" + } +} + +export class ConfigView extends Component { + constructor(props) { + super(props); + this.configRef = props.config; + } + + render() { + return <a class="a-button" onClick={e => alert("not supported now")}>conf</a> + } +} |