@cratis/fundamentals 7.22.3 → 7.22.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DateOnly.ts +28 -1
- package/JsonSerializer.ts +36 -14
- package/TimeOnly.ts +51 -11
- package/TimeSpan.ts +26 -1
- package/dist/DateOnly.d.ts +1 -0
- package/dist/DateOnly.d.ts.map +1 -1
- package/dist/DateOnly.js +21 -1
- package/dist/DateOnly.js.map +1 -1
- package/dist/JsonSerializer.d.ts.map +1 -1
- package/dist/JsonSerializer.js +29 -9
- package/dist/JsonSerializer.js.map +1 -1
- package/dist/TimeOnly.d.ts +2 -1
- package/dist/TimeOnly.d.ts.map +1 -1
- package/dist/TimeOnly.js +30 -4
- package/dist/TimeOnly.js.map +1 -1
- package/dist/TimeSpan.d.ts.map +1 -1
- package/dist/TimeSpan.js +17 -0
- package/dist/TimeSpan.js.map +1 -1
- package/dist/cjs/DateOnly.d.ts +1 -0
- package/dist/cjs/DateOnly.d.ts.map +1 -1
- package/dist/cjs/DateOnly.js +21 -1
- package/dist/cjs/DateOnly.js.map +1 -1
- package/dist/cjs/JsonSerializer.d.ts.map +1 -1
- package/dist/cjs/JsonSerializer.js +28 -8
- package/dist/cjs/JsonSerializer.js.map +1 -1
- package/dist/cjs/TimeOnly.d.ts +2 -1
- package/dist/cjs/TimeOnly.d.ts.map +1 -1
- package/dist/cjs/TimeOnly.js +30 -4
- package/dist/cjs/TimeOnly.js.map +1 -1
- package/dist/cjs/TimeSpan.d.ts.map +1 -1
- package/dist/cjs/TimeSpan.js +17 -0
- package/dist/cjs/TimeSpan.js.map +1 -1
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/typeKey.d.ts +3 -0
- package/dist/cjs/typeKey.d.ts.map +1 -1
- package/dist/cjs/typeKey.js +6 -0
- package/dist/cjs/typeKey.js.map +1 -1
- package/dist/esm/DateOnly.d.ts +1 -0
- package/dist/esm/DateOnly.d.ts.map +1 -1
- package/dist/esm/DateOnly.js +21 -1
- package/dist/esm/DateOnly.js.map +1 -1
- package/dist/esm/JsonSerializer.d.ts.map +1 -1
- package/dist/esm/JsonSerializer.js +29 -9
- package/dist/esm/JsonSerializer.js.map +1 -1
- package/dist/esm/TimeOnly.d.ts +2 -1
- package/dist/esm/TimeOnly.d.ts.map +1 -1
- package/dist/esm/TimeOnly.js +30 -4
- package/dist/esm/TimeOnly.js.map +1 -1
- package/dist/esm/TimeSpan.d.ts.map +1 -1
- package/dist/esm/TimeSpan.js +17 -0
- package/dist/esm/TimeSpan.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/typeKey.d.ts +3 -0
- package/dist/esm/typeKey.d.ts.map +1 -1
- package/dist/esm/typeKey.js +4 -1
- package/dist/esm/typeKey.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typeKey.d.ts +3 -0
- package/dist/typeKey.d.ts.map +1 -1
- package/dist/typeKey.js +3 -0
- package/dist/typeKey.js.map +1 -1
- package/for_DateOnly/when_parsing_an_out_of_range_calendar_date.ts +13 -0
- package/for_DateOnly/when_parsing_february_in_leap_and_common_years.ts +11 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_c_sharp_written_negative_time_span_keys.ts +19 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_c_sharp_written_time_only_keys.ts +19 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_c_sharp_written_whole_second_time_span_keys.ts +19 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_legacy_quoted_date_only_keys.ts +19 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_legacy_quoted_time_only_keys.ts +19 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_legacy_quoted_time_span_keys.ts +19 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_malformed_date_only_keys.ts +20 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_malformed_time_only_keys.ts +20 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_malformed_time_span_keys.ts +20 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_out_of_range_temporal_keys.ts +19 -0
- package/for_JsonSerializer/when_deserializing_out_of_range_temporal_values.ts +20 -0
- package/for_JsonSerializer/when_round_tripping_a_value_map_with_date_only_keys.ts +26 -0
- package/for_JsonSerializer/when_round_tripping_a_value_map_with_time_only_keys.ts +26 -0
- package/for_JsonSerializer/when_round_tripping_a_value_map_with_time_only_keys_differing_below_a_millisecond.ts +20 -0
- package/for_JsonSerializer/when_round_tripping_a_value_map_with_time_span_keys.ts +26 -0
- package/for_TimeOnly/when_creating_with_out_of_range_sub_millisecond_ticks.ts +11 -0
- package/for_TimeOnly/when_parsing_an_out_of_range_time_of_day.ts +11 -0
- package/for_TimeOnly/when_parsing_the_last_moment_of_the_day.ts +10 -0
- package/for_TimeOnly/when_parsing_the_shapes_the_server_sends.ts +6 -6
- package/for_TimeOnly/when_parsing_times_that_differ_below_a_millisecond.ts +14 -0
- package/for_TimeOnly/when_rendering_a_fraction.ts +11 -0
- package/for_TimeSpan/when_parsing_out_of_range_time.ts +11 -0
- package/for_TimeSpan/when_parsing_the_largest_in_range_time_span.ts +10 -0
- package/for_TimeSpan/when_parsing_time_beyond_what_a_time_span_can_hold.ts +11 -0
- package/package.json +1 -1
- package/typeKey.ts +9 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { TimeOnly } from '../TimeOnly';
|
|
5
|
+
|
|
6
|
+
describe('when parsing times that differ below a millisecond', () => {
|
|
7
|
+
const first = TimeOnly.parse('10:11:12.1234567');
|
|
8
|
+
const second = TimeOnly.parse('10:11:12.1239999');
|
|
9
|
+
|
|
10
|
+
it('should not be equal', () => first.equals(second).should.be.false);
|
|
11
|
+
it('should render the full seven digit fraction', () => first.toString().should.equal('10:11:12.1234567'));
|
|
12
|
+
it('should render differently', () => first.toJSON().should.not.equal(second.toJSON()));
|
|
13
|
+
it('should be equal to the same time written with trailing zeros', () => TimeOnly.parse('10:11:12.1230000').equals(TimeOnly.parse('10:11:12.123')).should.be.true);
|
|
14
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { TimeOnly } from '../TimeOnly';
|
|
5
|
+
|
|
6
|
+
describe('when rendering a fraction', () => {
|
|
7
|
+
it('should keep the three digit form when there is no part below the millisecond', () => TimeOnly.parse('10:11:12.1').toString().should.equal('10:11:12.100'));
|
|
8
|
+
it('should pad to seven digits when there is a part below the millisecond', () => TimeOnly.parse('10:11:12.1230100').toString().should.equal('10:11:12.1230100'));
|
|
9
|
+
it('should pad a short part below the millisecond', () => TimeOnly.parse('10:11:12.0000001').toString().should.equal('10:11:12.0000001'));
|
|
10
|
+
it('should render the time alone when there is no fraction', () => TimeOnly.parse('10:11:12').toString().should.equal('10:11:12'));
|
|
11
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { TimeSpan } from '../TimeSpan';
|
|
5
|
+
|
|
6
|
+
describe('when parsing out of range time', () => {
|
|
7
|
+
it('should reject minutes above 59', () => (() => TimeSpan.parse('00:60:00')).should.throw('minutes 60 is out of range'));
|
|
8
|
+
it('should reject seconds above 59', () => (() => TimeSpan.parse('00:00:60')).should.throw('seconds 60 is out of range'));
|
|
9
|
+
it('should reject hours above 23', () => (() => TimeSpan.parse('1.24:00:00')).should.throw('hours 24 is out of range'));
|
|
10
|
+
it('should reject hours above 23 without days', () => (() => TimeSpan.parse('25:00:00')).should.throw('hours 25 is out of range'));
|
|
11
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { TimeSpan } from '../TimeSpan';
|
|
5
|
+
|
|
6
|
+
describe('when parsing the largest in range time span', () => {
|
|
7
|
+
const parsed = TimeSpan.parse('1.23:59:59');
|
|
8
|
+
|
|
9
|
+
it('should render back to what it was parsed from', () => parsed.toString().should.equal('1.23:59:59'));
|
|
10
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { TimeSpan } from '../TimeSpan';
|
|
5
|
+
|
|
6
|
+
describe('when parsing time beyond what a time span can hold', () => {
|
|
7
|
+
it('should reject more days than the maximum', () => (() => TimeSpan.parse('10675200.00:00:00')).should.throw('days 10675200 is out of range'));
|
|
8
|
+
it('should reject the maximum days with a remainder above the maximum', () => (() => TimeSpan.parse('10675199.02:48:05.4775808')).should.throw('outside the range'));
|
|
9
|
+
it('should accept the maximum value', () => TimeSpan.parse('10675199.02:48:05.4775807').days.should.equal(10675199));
|
|
10
|
+
it('should accept the minimum value', () => TimeSpan.parse('-10675199.02:48:05.4775808').days.should.equal(-10675199));
|
|
11
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cratis/fundamentals",
|
|
3
|
-
"version": "7.22.
|
|
3
|
+
"version": "7.22.5",
|
|
4
4
|
"description": "The shared building blocks beneath the Cratis stack — GUIDs, concepts, derived-type serialization, property-path proxies, and decorators for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cratis",
|
package/typeKey.ts
CHANGED
|
@@ -55,3 +55,12 @@ export const valueMapTypeKey = 'ValueMap';
|
|
|
55
55
|
|
|
56
56
|
/** The key `Guid` declares. */
|
|
57
57
|
export const guidTypeKey = 'Guid';
|
|
58
|
+
|
|
59
|
+
/** The key `DateOnly` declares. */
|
|
60
|
+
export const dateOnlyTypeKey = 'DateOnly';
|
|
61
|
+
|
|
62
|
+
/** The key `TimeOnly` declares. */
|
|
63
|
+
export const timeOnlyTypeKey = 'TimeOnly';
|
|
64
|
+
|
|
65
|
+
/** The key `TimeSpan` declares. */
|
|
66
|
+
export const timeSpanTypeKey = 'TimeSpan';
|