@bodar/totallylazy
Advanced tools
Comparing version 0.466.308 to 0.467.309
@@ -0,1 +1,2 @@ | ||
import { DateFactory } from "./parsing"; | ||
declare global { | ||
@@ -28,11 +29,2 @@ interface String { | ||
export declare type Format = string; | ||
export interface DateFactory { | ||
create(parts: DateFactoryParts): Date; | ||
} | ||
export interface DateFactoryParts { | ||
day: number; | ||
month: Month; | ||
year?: number; | ||
weekday?: Weekday; | ||
} | ||
export interface Options { | ||
@@ -39,0 +31,0 @@ year?: 'numeric' | '2-digit'; |
@@ -5,3 +5,2 @@ export * from './core'; | ||
export * from './datum'; | ||
export * from "./Days"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -8,3 +8,2 @@ "use strict"; | ||
tslib_1.__exportStar(require("./datum"), exports); | ||
tslib_1.__exportStar(require("./Days"), exports); | ||
//# sourceMappingURL=index.js.map |
import { NamedMatch, NamedRegExp } from "../characters"; | ||
import { DateFactory, DateFactoryParts, Format, Options } from "./index"; | ||
import { Format, Month, Options, Weekday } from "./index"; | ||
import { Parser } from "../parsing"; | ||
@@ -29,2 +29,11 @@ import { Clock } from "./clock"; | ||
export declare function dateFrom(parts: DateTimeFormatPart[], locale: string, factory?: DateFactory): Date; | ||
export interface DateFactoryParts { | ||
day: number; | ||
month: Month; | ||
year?: number; | ||
weekday?: Weekday; | ||
} | ||
export interface DateFactory { | ||
create(parts: DateFactoryParts): Date; | ||
} | ||
export declare class DefaultDateFactory implements DateFactory { | ||
@@ -74,2 +83,9 @@ create({ year, month, day }: DateFactoryParts): Date; | ||
} | ||
export declare class Days { | ||
static milliseconds: number; | ||
static startOf(value: Date): Date; | ||
static add(date: Date, days: number): Date; | ||
static subtract(date: Date, days: number): Date; | ||
static between(a: Date, b: Date): number; | ||
} | ||
export declare function formatFrom(type: DateTimeFormatPartTypes, length: number): string; | ||
@@ -76,0 +92,0 @@ export declare const formatRegex: NamedRegExp; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.localeParser = exports.simpleParser = exports.parser = exports.defaultParserOptions = exports.formatBuilder = exports.optionsFrom = exports.partsFrom = exports.formatRegex = exports.formatFrom = exports.SmartDate = exports.Pivot = exports.InferYear = exports.InferDirection = exports.InferYearViaWeekday = exports.compositeDateFactory = exports.DefaultDateFactory = exports.dateFrom = exports.DateTimeFormatPartParser = exports.DateParser = exports.escapeCharacters = exports.RegexBuilder = exports.parse = void 0; | ||
exports.localeParser = exports.simpleParser = exports.parser = exports.defaultParserOptions = exports.formatBuilder = exports.optionsFrom = exports.partsFrom = exports.formatRegex = exports.formatFrom = exports.Days = exports.SmartDate = exports.Pivot = exports.InferYear = exports.InferDirection = exports.InferYearViaWeekday = exports.compositeDateFactory = exports.DefaultDateFactory = exports.dateFrom = exports.DateTimeFormatPartParser = exports.DateParser = exports.escapeCharacters = exports.RegexBuilder = exports.parse = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -181,3 +181,3 @@ const lazy_1 = require("../lazy"); | ||
candidates(month, day) { | ||
const now = index_1.Days.startOf(this.clock.now()); | ||
const now = Days.startOf(this.clock.now()); | ||
return collections_1.array(sequence_1.range(0, -6), transducers_1.zip(sequence_1.range(1, 6)), transducers_1.flatMap(a => a), parsing_1.mapIgnoreError(inc => index_1.date(index_1.yearOf(now) + inc, month, day))); | ||
@@ -195,3 +195,3 @@ } | ||
this.direction = direction; | ||
this.date = index_1.Days.startOf(date); | ||
this.date = Days.startOf(date); | ||
} | ||
@@ -266,2 +266,20 @@ static before(date) { | ||
exports.SmartDate = SmartDate; | ||
class Days { | ||
static startOf(value) { | ||
return index_1.date(index_1.yearOf(value), index_1.monthOf(value), index_1.dayOf(value)); | ||
} | ||
static add(date, days) { | ||
const newDate = new Date(date.getTime()); | ||
newDate.setUTCDate(date.getUTCDate() + days); | ||
return newDate; | ||
} | ||
static subtract(date, days) { | ||
return Days.add(date, days * -1); | ||
} | ||
static between(a, b) { | ||
return Math.abs((a.getTime() - b.getTime()) / Days.milliseconds); | ||
} | ||
} | ||
exports.Days = Days; | ||
Days.milliseconds = 24 * 60 * 60 * 1000; | ||
function formatFrom(type, length) { | ||
@@ -268,0 +286,0 @@ if (type === 'year') { |
{ | ||
"name": "@bodar/totallylazy", | ||
"version": "0.466.308", | ||
"version": "0.467.309", | ||
"description": "Totallylazy", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:bodar/totallylazy.js.git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
461911
143
6748