~ehamberg/paw-unix-time

5c37bf3a10313072925378514dcc6a7e6c2a4f8b — Erlend Hamberg 5 years ago 6c3b216
Rename to “Unix Time”
2 files changed, 11 insertions(+), 11 deletions(-)

M README.md
R Iso8601ToPosix.js => UnixTime.js
M README.md => README.md +3 -3
@@ 1,6 1,6 @@
# Iso8601ToPosix
# Unix Time

Simple [Paw](https://paw.cloud) dynamic value for converting from ISO 8601 to
POSIX/Unix time (seconds since 1970-01-01).
Simple [Paw](https://paw.cloud) dynamic value for converting from e.g. ISO 8601
to POSIX/Unix time (seconds since 1970-01-01).

Licence: BSD-3-Clause OR Apache-2.0

R Iso8601ToPosix.js => UnixTime.js +8 -8
@@ 3,7 3,7 @@ const pad = n => n<10 ? '0'+n : n;
const ISODateString = d =>
    d.getUTCFullYear()+'-' + pad(d.getUTCMonth()+1)+'-' + pad(d.getUTCDate())+'T00:00Z';

class Iso8601ToPosix {
class UnixTime {
    evaluate() {
        const ms = Date.parse(this.value);



@@ 12,15 12,15 @@ class Iso8601ToPosix {
        return ms/1000|0;
    }

    text() { return isNaN(Date.parse(this.value)) ? "invalid" : this.value; }
    text() { return isNaN(Date.parse(this.value)) ? "invalid date/time" : this.value; }
}

Iso8601ToPosix.inputs = [
    InputField("value", "Value", "String", {defaultValue: ISODateString(new Date())}),
UnixTime.inputs = [
    InputField("value", "ISO 8601 date/time", "String", {defaultValue: ISODateString(new Date())}),
];

Iso8601ToPosix.title = "ISO 8601 to Posix";
Iso8601ToPosix.help = "https://git.sr.ht/~ehamberg/paw-iso8601-to-posix";
Iso8601ToPosix.identifier = "no.hamberg.Iso8601ToPosix";
UnixTime.title = "Unix Time";
UnixTime.help = "https://git.sr.ht/~ehamberg/paw-unix-time";
UnixTime.identifier = "no.hamberg.UnixTime";

registerDynamicValueClass(Iso8601ToPosix)
registerDynamicValueClass(UnixTime)