From 4b9fdd37229a0c72905e9a7d5bcfcea5f18caddf Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Tue, 24 Oct 2017 19:53:15 +0200 Subject: [PATCH] Type definitions for moment-strftime2 1.0 (#20873) --- types/moment-strftime2/index.d.ts | 88 +++++++++++++++++++ .../moment-strftime2-tests.ts | 8 ++ types/moment-strftime2/tsconfig.json | 23 +++++ types/moment-strftime2/tslint.json | 1 + 4 files changed, 120 insertions(+) create mode 100644 types/moment-strftime2/index.d.ts create mode 100644 types/moment-strftime2/moment-strftime2-tests.ts create mode 100644 types/moment-strftime2/tsconfig.json create mode 100644 types/moment-strftime2/tslint.json diff --git a/types/moment-strftime2/index.d.ts b/types/moment-strftime2/index.d.ts new file mode 100644 index 0000000000..914b175a5b --- /dev/null +++ b/types/moment-strftime2/index.d.ts @@ -0,0 +1,88 @@ +// Type definitions for moment-strftime2 1.0 +// Project: https://github.com/ShogunPanda/moment-strftime2 +// Definitions by: Piotr Roszatycki +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import * as _moment from 'moment'; + +declare module "moment" { + interface Moment { + strftime(pattern: string): string; + } +} + +declare module "moment-timezone" { + interface Moment { + strftime(pattern: string): string; + } +} + +// tslint:disable:export-just-namespace +// because separator has to be read-write + +declare namespace MomentStrftime2 { + interface Modifiers { + "%": string; + A: string; + B: string; + C?: string; + D: string; + E?: string; + F: string; + G?: string; + H: string; + I: string; + J?: string; + K?: string; + L: string; + M: string; + N?: string; + O?: string; + P: string; + Q?: string; + R: string; + S: string; + T: string; + U?: string; + V: string; + W: string; + X?: string; + Y: string; + Z: string; + a: string; + b: string; + c?: string; + d: string; + e: string; + f?: string; + g: string; + h: string; + i?: string; + j: string; + k: string; + l: string; + m: string; + n?: string; + o?: string; + p: string; + q?: string; + r: string; + s: string; + t?: string; + u: string; + v?: string; + w: string; + x?: string; + y: string; + z: string; + } + + let modifiers: Modifiers; + + let separator: string; + + function installTo(moment: object): void; +} + +export = MomentStrftime2; diff --git a/types/moment-strftime2/moment-strftime2-tests.ts b/types/moment-strftime2/moment-strftime2-tests.ts new file mode 100644 index 0000000000..91441bfdd9 --- /dev/null +++ b/types/moment-strftime2/moment-strftime2-tests.ts @@ -0,0 +1,8 @@ +import moment = require("moment-timezone"); +import strftime2 = require("moment-strftime2"); +strftime2.installTo(moment); + +moment("2016-10-10 12:34:56.135 +02:00").strftime("%d %o #d #o"); // "10 %o #d #o" +strftime2.separator = "$"; +strftime2.modifiers.o = "DD"; +moment("2016-10-10 12:34:56.135 +02:00").strftime("%d %o #d #o"); // "%d %o 10 10" diff --git a/types/moment-strftime2/tsconfig.json b/types/moment-strftime2/tsconfig.json new file mode 100644 index 0000000000..cd5862e99f --- /dev/null +++ b/types/moment-strftime2/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "moment-strftime2-tests.ts" + ] +} diff --git a/types/moment-strftime2/tslint.json b/types/moment-strftime2/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/moment-strftime2/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }