1 | /**
|
2 | * Converts arbitrary values into longs using extended conversion rules:
|
3 | * - Strings are converted to floats, then to longs
|
4 | * - DateTime: total number of milliseconds since unix epoсh
|
5 | * - Boolean: 1 for true and 0 for false
|
6 | *
|
7 | * ### Example ###
|
8 | *
|
9 | * let value1 = LongConverter.toNullableLong("ABC"); // Result: null
|
10 | * let value2 = LongConverter.toNullableLong("123.456"); // Result: 123
|
11 | * let value3 = LongConverter.toNullableLong(true); // Result: 1
|
12 | * let value4 = LongConverter.toNullableLong(new Date()); // Result: current milliseconds
|
13 | */
|
14 | export declare class LongConverter {
|
15 | /**
|
16 | * Converts value into long or returns null when conversion is not possible.
|
17 | *
|
18 | * @param value the value to convert.
|
19 | * @returns long value or null when conversion is not supported.
|
20 | */
|
21 | static toNullableLong(value: any): number;
|
22 | /**
|
23 | * Converts value into long or returns 0 when conversion is not possible.
|
24 | *
|
25 | * @param value the value to convert.
|
26 | * @returns long value or 0 when conversion is not supported.
|
27 | *
|
28 | * @see [[toLongWithDefault]]
|
29 | */
|
30 | static toLong(value: any): number;
|
31 | /**
|
32 | * Converts value into integer or returns default when conversion is not possible.
|
33 | *
|
34 | * @param value the value to convert.
|
35 | * @param defaultValue the default value.
|
36 | * @returns long value or default when conversion is not supported
|
37 | *
|
38 | * @see [[toNullableLong]]
|
39 | */
|
40 | static toLongWithDefault(value: any, defaultValue: number): number;
|
41 | }
|