summaryrefslogtreecommitdiffstats
path: root/front/config.jsx
blob: 51373cc489a63ba71555b7928ebffb2b2d3e767b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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>
    }
}