@omnicar/sam-format
Advanced tools
Comparing version 0.0.36 to 0.0.37
@@ -0,0 +0,0 @@ import { IsoLocale } from '@omnicar/sam-types'; |
@@ -6,2 +6,4 @@ "use strict"; | ||
var date_fns_1 = require("date-fns"); | ||
var invalidDateErrorMessage = 'Error: Invalid Date'; | ||
var invalidDateReturnValue = '--Invalid Date--'; | ||
/* | ||
@@ -11,5 +13,5 @@ Ref: https://date-fns.org/v2.10.0/docs/I18n | ||
It might seem complicated to require and pass locales as options, | ||
but unlike Moment.js which bloats your build with all the locales | ||
but unlike Moment.js which bloats your build with all the locales, | ||
by default date-fns forces developer to manually require | ||
locales when needed. | ||
all the locales needed. | ||
" | ||
@@ -38,3 +40,3 @@ */ | ||
console.error('Error while trying to convert date string to date', error); | ||
throw error; | ||
return invalidDateReturnValue; | ||
} | ||
@@ -99,3 +101,3 @@ } | ||
var formatted = ''; | ||
// load locale data | ||
// Load locale data. | ||
var dateConfig = init_2.currentLocale.date, separators = init_2.currentLocale.separators; | ||
@@ -111,6 +113,7 @@ if (dateConfig && separators) { | ||
catch (error) { | ||
// The formatter failed to initialize. | ||
console.error(error); | ||
throw Error(error); | ||
throw Error(error); // This is a "serious" error, throw error! | ||
} | ||
// format time | ||
// Format time. | ||
var minuteSep = separators.minute; | ||
@@ -122,3 +125,4 @@ var timeFormat = !dateConfig.name.short | ||
if (!rawFormat && !date_fns_1.isValid(date)) { | ||
throw Error('Invalid Date'); | ||
console.error(invalidDateErrorMessage); | ||
return invalidDateReturnValue; | ||
} | ||
@@ -129,7 +133,7 @@ formatted = date_fns_1.format(date, rawFormat || createdFormat, { | ||
} | ||
// if invalid date | ||
if (formatted.toLowerCase().includes('invalid')) { | ||
throw Error(formatted); | ||
console.error(invalidDateErrorMessage); | ||
return invalidDateReturnValue; | ||
} | ||
return formatted; | ||
} |
@@ -0,0 +0,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ import { IsoLocale } from '@omnicar/sam-types'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ import { IFormattedNumberOptions as ISamFormattedNumberOptions } from './IFormattedNumberOptions'; |
@@ -0,0 +0,0 @@ "use strict"; |
import { IFormattedNumberOptions } from '../IFormattedNumberOptions'; | ||
export declare function formatCurrency(price: number, { showDecimals, symbolDisplayType, }?: IFormattedNumberOptions): string; |
@@ -0,0 +0,0 @@ "use strict"; |
import { IFormattedNumberOptions } from '../IFormattedNumberOptions'; | ||
export declare function formatMileage(mileage: number | string, opts?: IFormattedNumberOptions): string; |
@@ -0,0 +0,0 @@ "use strict"; |
export declare function formatNumber(number: number, showDecimals?: boolean): string; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { NumberType, SymbolDisplayType } from './NumberTypes'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
export declare type NumberType = 'MILEAGE' | 'CURRENCY' | 'NUMBER'; | ||
export declare type SymbolDisplayType = 'APPEND' | 'PREPEND' | 'NONE'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ export { formatDate, formatLocalizedDate } from './formatDate/formatDate'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { ISamFormatOptions } from './ISamFormatOptions'; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IsoLocale } from '@omnicar/sam-types'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ export interface ILocaleConfiguration { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -50,3 +50,3 @@ { | ||
}, | ||
"version": "0.0.36" | ||
"version": "0.0.37" | ||
} |
@@ -0,0 +0,0 @@ # SAM-format |
25448
35
672