@ygracs/xepg-lib-js 0.0.26-b → 0.0.30
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/CHANGELOG.md +16 -3
- package/README.md +4 -2
- package/doc/xepgdoc-lib.md +67 -55
- package/index.d.ts +27 -21
- package/index.js +13 -3
- package/lib/dts-helper.d.ts +53 -37
- package/lib/dts-helper.js +73 -42
- package/lib/xepg-channel.d.ts +91 -0
- package/lib/xepg-channel.js +308 -0
- package/lib/xepg-defs.d.ts +67 -0
- package/lib/xepg-defs.js +88 -0
- package/lib/xepg-sched.d.ts +231 -0
- package/lib/xepg-sched.js +587 -0
- package/lib/xepgdoc-lib.d.ts +338 -596
- package/lib/xepgdoc-lib.js +306 -1106
- package/lib/xml-base.d.ts +40 -21
- package/lib/xml-base.js +98 -23
- package/package.json +11 -8
- /package/doc/{xepgdoc-example.xepg → xepgdoc-example-s02.xepg} +0 -0
- /package/doc/{xepgdoc-spec.md → xepgdoc-spec-02.md} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
#### *v0.0.
|
|
1
|
+
#### *v0.0.30*
|
|
2
2
|
|
|
3
3
|
Pre-release version.
|
|
4
4
|
|
|
5
|
-
> - update
|
|
5
|
+
> - update `xepgdoc-lib.md`;
|
|
6
|
+
> - update dependency on `@ygracs/xml-js6` module to v0.0.9-b;
|
|
7
|
+
> - update dependency on `@ygracs/bsfoc-lib-js` module to v0.3.4;
|
|
6
8
|
> - update dependency on `@ygracs/dtf-lib-js` module to v0.0.33;
|
|
7
|
-
> - update dependency on `@
|
|
9
|
+
> - update dependency on `@ygracs/xobj-lib-js` module to v0.3.3;
|
|
10
|
+
> - update dependency on `@cntwg/file-helper` module to v0.0.4;
|
|
11
|
+
> - add new class: `TXmlContentDeclaration`;
|
|
12
|
+
> - (`TXEpgContentProvider`) change behavior for methods: `loadFromFile`, `loadFromFileSync`;
|
|
13
|
+
> - (`TXEpgContentProvider`) remove deprecated properties: `SchedulesList`;
|
|
14
|
+
> - (`TXEpgHeaderContainer`) remove deprecated methods: `setProviderInfo`, `setChannelInfo`;
|
|
15
|
+
> - (`TXEpgProviderContainer`) change behavior for methods: `init`;
|
|
16
|
+
> - (`TXEpgChannelContainer`) change behavior for methods: `setInfo`;
|
|
17
|
+
> - (`TXEpgSchedulesList`) add new methods: `checkIndex`;
|
|
18
|
+
> - (`TXEpgSchedulesList`) deprecate methods: `chkIndex`;
|
|
19
|
+
> - (`TXEpgSchedulesList`) remove deprecated methods: `hasSchedules`, `hasNoSchedules`;
|
|
20
|
+
> - other fixes.
|
|
8
21
|
|
|
9
22
|
#### *v0.0.25*
|
|
10
23
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|***rev.*:**|0.0.
|
|
1
|
+
|***rev.*:**|0.0.12|
|
|
2
2
|
|:---|---:|
|
|
3
|
-
|***date***:|
|
|
3
|
+
|***date***:|2026-06-12|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -48,3 +48,5 @@ For more read the `xepgdoc-lib.md` in the project `doc` directory.
|
|
|
48
48
|
### Installation
|
|
49
49
|
|
|
50
50
|
`npm install @ygracs/xepg-lib-js`
|
|
51
|
+
|
|
52
|
+
> Note: It's recommended to "pin" a package versions range to its minor releases after installation. To do so use `~` range specifier (*e.g. `~0.0.30`*) in `package.json`.
|
package/doc/xepgdoc-lib.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|***rev.*:**|0.1.
|
|
1
|
+
|***rev.*:**|0.1.46|
|
|
2
2
|
|:---|---:|
|
|
3
|
-
|***date***:|
|
|
3
|
+
|***date***:|2026-06-12|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -322,11 +322,6 @@ The class constructor receives arguments listed below:
|
|
|
322
322
|
|
|
323
323
|
#### class methods
|
|
324
324
|
|
|
325
|
-
<a name="TXEpgSchedulesList+hasNoSchedules"></a>
|
|
326
|
-
##### **hasNoSchedules()** => `boolean`
|
|
327
|
-
|
|
328
|
-
> \[!] NOTE: `[since v0.0.24]` deprecated. Use [`isEmpty` method](#TXEpgSchedulesList+isEmpty) instead.
|
|
329
|
-
|
|
330
325
|
<a name="TXEpgSchedulesList+isEmpty"></a>
|
|
331
326
|
##### **isEmpty()** => `boolean`
|
|
332
327
|
|
|
@@ -334,11 +329,6 @@ The class constructor receives arguments listed below:
|
|
|
334
329
|
|
|
335
330
|
This method returns `true` if a document contains no schedules.
|
|
336
331
|
|
|
337
|
-
<a name="TXEpgSchedulesList+hasSchedules"></a>
|
|
338
|
-
##### **hasSchedules()** => `boolean`
|
|
339
|
-
|
|
340
|
-
> \[!] NOTE: `[since v0.0.24]` deprecated. Use [`isNotEmpty` method](#TXEpgSchedulesList+isNotEmpty) instead.
|
|
341
|
-
|
|
342
332
|
<a name="TXEpgSchedulesList+isNotEmpty"></a>
|
|
343
333
|
##### **isNotEmpty()** => `boolean`
|
|
344
334
|
|
|
@@ -351,11 +341,18 @@ This method returns `true` if a document contains at least one schedule.
|
|
|
351
341
|
|
|
352
342
|
> since: `v0.0.20`
|
|
353
343
|
|
|
354
|
-
|
|
344
|
+
> WARNING: \[since `v0.0.30`] this method deprecated (*use [`checkIndex`](#TXEpgSchedulesList+checkIndex) method instead*).
|
|
345
|
+
|
|
346
|
+
<a name="TXEpgSchedulesList+checkIndex"></a>
|
|
347
|
+
##### **checkIndex(value)** => `boolean`
|
|
348
|
+
|
|
349
|
+
> since: \[`v0.0.30`]
|
|
350
|
+
|
|
351
|
+
This method checks if the given `value` represents a valid index value and fits the range of all possible indexes belonging to the list instance. If so `true` is returned.
|
|
355
352
|
|
|
356
353
|
| parameter name | value type | default value | description |
|
|
357
354
|
|:---|---|---:|:---|
|
|
358
|
-
| `value` | `number
|
|
355
|
+
| `value` | `number` or `string` | --- | a value to be verified |
|
|
359
356
|
|
|
360
357
|
<a name="TXEpgSchedulesList+schedule"></a>
|
|
361
358
|
##### **schedule(index)** => `TXEpgScheduleItem`
|
|
@@ -523,8 +520,8 @@ The class constructor receives arguments listed below:
|
|
|
523
520
|
|
|
524
521
|
| parameter name | value type | default value | description |
|
|
525
522
|
|:---|---|---:|:---|
|
|
526
|
-
|
|
527
|
-
|
|
523
|
+
| `object` | `object` | --- | a host object |
|
|
524
|
+
| `options` | `object` | --- | an options settings |
|
|
528
525
|
|
|
529
526
|
#### class properties
|
|
530
527
|
|
|
@@ -739,45 +736,11 @@ An object contains the following fields:
|
|
|
739
736
|
|`chname`|`string`|a name of the channel|
|
|
740
737
|
|`srcurl`|`string`|a link to source|
|
|
741
738
|
|
|
742
|
-
<a name="TXEpgHeaderContainer+setChannelInfo"></a>
|
|
743
|
-
##### **setChannelInfo(obj)** => `void`
|
|
744
|
-
|
|
745
|
-
> \[!] WARNING: `[since v0.0.22]` deprecated. Use [`TXEpgChannelContainer.setInfo()`](#TXEpgChannelContainer+setInfo) instead.
|
|
746
|
-
|
|
747
|
-
This method fills a channel information with a given data.
|
|
748
|
-
|
|
749
|
-
| parameter name | value type | default value | description |
|
|
750
|
-
|:---|---|---:|:---|
|
|
751
|
-
| `obj` | `xepgChnInfoDesc` | --- | channel info descriptor |
|
|
752
|
-
|
|
753
|
-
> \[!] NOTE: `[since v0.0.21]` a use of a `string` or `array` types a as values of an `obj` are deprecated and will be dropped soon.
|
|
754
|
-
|
|
755
|
-
The `obj` parameter can be a string or an array or an object.
|
|
756
|
-
|
|
757
|
-
If a string is given it mean to contains the `chnid` value.
|
|
758
|
-
|
|
759
|
-
If an array is given it contains the following fields:
|
|
760
|
-
|
|
761
|
-
`[ <chnid>, <chname>, <chngid>, <srcurl> ]`
|
|
762
|
-
|
|
763
|
-
If an object is given it contains the following fields:
|
|
764
|
-
|
|
765
|
-
|field name|field type|description|
|
|
766
|
-
|:---|---|:---|
|
|
767
|
-
|`chnid`|`string`|a channel ID|
|
|
768
|
-
|`chname`|`string`|a name of the channel|
|
|
769
|
-
|`chngid`|`string`|a channel group|
|
|
770
|
-
|`srcurl`|`string`|a link to source|
|
|
771
|
-
|
|
772
739
|
<a name="TXEpgHeaderContainer+getProviderInfo"></a>
|
|
773
740
|
##### **getProviderInfo()** => `xepgProvInfoDesc`
|
|
774
741
|
|
|
775
742
|
This method returns an object which contains an information about document provider.
|
|
776
743
|
|
|
777
|
-
##### **setProviderInfo(obj)**
|
|
778
|
-
|
|
779
|
-
> \[!] WARNING: `[since v0.0.24]` deprecated. Use [`TXEpgProviderContainer.setInfo()`](#TXEpgProviderContainer+setInfo) instead.
|
|
780
|
-
|
|
781
744
|
<a name="TXEpgHeaderContainer+saveToXMLString"></a>
|
|
782
745
|
##### **saveToXMLString()** => `string`
|
|
783
746
|
|
|
@@ -804,6 +767,60 @@ This method loads an element content from a string given by a `str` parameter.
|
|
|
804
767
|
|
|
805
768
|
This methods throws `Error` if something goes wrong through a parsing process of a string.
|
|
806
769
|
|
|
770
|
+
<a name="TXmlContentDeclaration"></a>
|
|
771
|
+
### **TXmlContentDeclaration**
|
|
772
|
+
|
|
773
|
+
> since: `v0.0.30`
|
|
774
|
+
|
|
775
|
+
This class implements a proxy interface for a document declaration element.
|
|
776
|
+
|
|
777
|
+
#### class constructor
|
|
778
|
+
|
|
779
|
+
The class constructor creates a new instance of the class.
|
|
780
|
+
|
|
781
|
+
##### constructor parameters
|
|
782
|
+
|
|
783
|
+
The class constructor receives an arguments listed below:
|
|
784
|
+
|
|
785
|
+
| parameter name | value type | default value | description |
|
|
786
|
+
|:---|---|---:|:---|
|
|
787
|
+
| `object` | `object` | --- | a host object for the document content |
|
|
788
|
+
| `options` | `object` | --- | an options settings |
|
|
789
|
+
|
|
790
|
+
###### `options` parameter
|
|
791
|
+
|
|
792
|
+
The `options` structure is listed below:
|
|
793
|
+
|
|
794
|
+
| option name | value type | default value | description |
|
|
795
|
+
|:---|---|---:|:---|
|
|
796
|
+
| `parseOptions` | `object` | `EMPTY_OBJECT` | contains a XML-parse options (see description for `XML_DEF_PARSE_OPTIONS`) |
|
|
797
|
+
|
|
798
|
+
##### exceptions
|
|
799
|
+
|
|
800
|
+
If `object` parameter is not a type of `object` or not given a `TypeError` thrown.
|
|
801
|
+
|
|
802
|
+
#### class properties
|
|
803
|
+
|
|
804
|
+
<a name="TXmlContentDeclaration+version"></a>
|
|
805
|
+
##### **version**
|
|
806
|
+
|
|
807
|
+
| property type | read only | description |
|
|
808
|
+
|---|---|:---|
|
|
809
|
+
| `string` | no | returns a version of an XML |
|
|
810
|
+
|
|
811
|
+
<a name="TXmlContentDeclaration+encoding"></a>
|
|
812
|
+
##### **encoding**
|
|
813
|
+
|
|
814
|
+
| property type | read only | description |
|
|
815
|
+
|---|---|:---|
|
|
816
|
+
| `string` | no | returns a name of the character set used by the document |
|
|
817
|
+
|
|
818
|
+
#### class methods (*special*)
|
|
819
|
+
|
|
820
|
+
##### **init()** => `void`
|
|
821
|
+
|
|
822
|
+
This method initializes an element with a default values.
|
|
823
|
+
|
|
807
824
|
<a name="TXEpgContentProvider"></a>
|
|
808
825
|
### **TXEpgContentProvider**
|
|
809
826
|
|
|
@@ -853,11 +870,6 @@ The `options` structure is listed below:
|
|
|
853
870
|
|---|---|:---|
|
|
854
871
|
| `TXEpgDTSProvider` | yes | returns a `TXEpgDTSProvider` instance |
|
|
855
872
|
|
|
856
|
-
<a name="TXEpgContentProvider+SchedulesList"></a>
|
|
857
|
-
##### **SchedulesList**
|
|
858
|
-
|
|
859
|
-
> \[!] NOTE: `[since v0.0.24]` deprecated. Use [`schedules` property](#TXEpgContentProvider+schedules) instead.
|
|
860
|
-
|
|
861
873
|
<a name="TXEpgContentProvider+schedules"></a>
|
|
862
874
|
##### **schedules**
|
|
863
875
|
|
package/index.d.ts
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "./lib/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { TXEpgScheduleItem } from "./lib/xepg-sched";
|
|
2
|
+
import { TXEpgSchedulesList } from "./lib/xepg-sched";
|
|
3
|
+
import { TXEpgChannelContainer } from "./lib/xepg-channel";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
TXmlContentParseOptions,
|
|
7
|
+
} from "@ygracs/xobj-lib-js";
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
TXEpgContentProvider,
|
|
11
|
+
TXEpgDTSProvider, TXEpgProviderContainer, TXEpgHeaderContainer,
|
|
12
|
+
TXmlContentDeclaration,
|
|
13
|
+
} from "./lib/xepgdoc-lib";
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
readAsTagName, readAsAttrName, readAsAttrValue, valueToElementID,
|
|
17
|
+
} from "./lib/xml-base";
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
TXEpgContentProvider,
|
|
21
|
+
TXEpgScheduleItem, TXEpgSchedulesList,
|
|
22
|
+
TXEpgDTSProvider, TXEpgProviderContainer, TXEpgHeaderContainer,
|
|
23
|
+
TXEpgChannelContainer,
|
|
24
|
+
TXmlContentDeclaration,
|
|
25
|
+
readAsTagName, readAsAttrName, readAsAttrValue, valueToElementID,
|
|
26
|
+
TXmlContentParseOptions,
|
|
27
|
+
};
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.017-20260531]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -8,6 +8,14 @@ const xObj = require('@ygracs/xobj-lib-js');
|
|
|
8
8
|
|
|
9
9
|
const xmlBase = require('./lib/xml-base');
|
|
10
10
|
|
|
11
|
+
const {
|
|
12
|
+
TXEpgScheduleItem, TXEpgSchedulesList,
|
|
13
|
+
} = require('./lib/xepg-sched');
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
TXEpgChannelContainer,
|
|
17
|
+
} = require('./lib/xepg-channel');
|
|
18
|
+
|
|
11
19
|
// === module inner block ===
|
|
12
20
|
|
|
13
21
|
// === module main block ===
|
|
@@ -15,12 +23,14 @@ const xmlBase = require('./lib/xml-base');
|
|
|
15
23
|
// === module exports block ===
|
|
16
24
|
|
|
17
25
|
/**/// v1 branch
|
|
26
|
+
module.exports.TXEpgScheduleItem = TXEpgScheduleItem;
|
|
27
|
+
module.exports.TXEpgSchedulesList = TXEpgSchedulesList;
|
|
28
|
+
module.exports.TXEpgChannelContainer = TXEpgChannelContainer;
|
|
18
29
|
module.exports.TXEpgContentProvider = xepgdoc.TXEpgContentProvider;
|
|
19
|
-
module.exports.TXEpgScheduleItem = xepgdoc.TXEpgScheduleItem;
|
|
20
|
-
module.exports.TXEpgSchedulesList = xepgdoc.TXEpgSchedulesList;
|
|
21
30
|
module.exports.TXEpgDTSProvider = xepgdoc.TXEpgDTSProvider;
|
|
22
31
|
module.exports.TXEpgProviderContainer = xepgdoc.TXEpgProviderContainer;
|
|
23
32
|
module.exports.TXEpgHeaderContainer = xepgdoc.TXEpgHeaderContainer;
|
|
33
|
+
module.exports.TXmlContentDeclaration = xepgdoc.TXmlContentDeclaration;
|
|
24
34
|
|
|
25
35
|
module.exports.readAsTagName = xmlBase.readAsTagName;
|
|
26
36
|
module.exports.readAsAttrName = xmlBase.readAsAttrName;
|
package/lib/dts-helper.d.ts
CHANGED
|
@@ -1,37 +1,53 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A 'DTS'-type descriptor
|
|
3
|
-
*/
|
|
4
|
-
export type
|
|
5
|
-
/**
|
|
6
|
-
* - dtstype ID
|
|
7
|
-
*/
|
|
8
|
-
index: number;
|
|
9
|
-
/**
|
|
10
|
-
* - dtstype name
|
|
11
|
-
*/
|
|
12
|
-
name: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
* @todo
|
|
30
|
-
*/
|
|
31
|
-
export function
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A 'DTS'-type descriptor
|
|
3
|
+
*/
|
|
4
|
+
export type IDTSysDescr = {
|
|
5
|
+
/**
|
|
6
|
+
* - dtstype ID
|
|
7
|
+
*/
|
|
8
|
+
index: number;
|
|
9
|
+
/**
|
|
10
|
+
* - dtstype name
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
export const IDTSysDescr: IDTSysDescr;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @inner
|
|
19
|
+
*/
|
|
20
|
+
export function _getDTSTypeValueForXObj(obj: object | null, parseOptions?: object): number;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @inner
|
|
24
|
+
*/
|
|
25
|
+
export function _getTZSrcValueFromXObj(obj: object | null, parseOptions?: object): number;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a given value is a valid dtstype ID
|
|
28
|
+
* @deprecated
|
|
29
|
+
* @todo \[since `v0.0.25`] deprecated. Use {@link checkDTSysID} instead
|
|
30
|
+
*/
|
|
31
|
+
export function chkDTSysID(value: number | string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Checks if a given value is a valid dtstype ID
|
|
34
|
+
*/
|
|
35
|
+
export function checkDTSysID(value: number | string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Returns a dtstype name by a given dtstype ID
|
|
38
|
+
*/
|
|
39
|
+
export function getDTSysName(value: number | string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Returns a dtstype description for a given dtstype ID
|
|
42
|
+
*/
|
|
43
|
+
export function getDTSysDescr(value: number | string): IDTSysDescr;
|
|
44
|
+
/**
|
|
45
|
+
* Tries to convert a given string to timestamp
|
|
46
|
+
* @todo check TZ
|
|
47
|
+
*/
|
|
48
|
+
export function convStringToDTValue(value: string, dts_id?: number | string, tz?: number | string): number;
|
|
49
|
+
/**
|
|
50
|
+
* Tries to convert a given value to its string representation
|
|
51
|
+
* @todo check TZ
|
|
52
|
+
*/
|
|
53
|
+
export function convDTValueToString(value: number | string | Date, dts_id?: number | string, tz?: number | string): string;
|
package/lib/dts-helper.js
CHANGED
|
@@ -1,71 +1,116 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.053-20260531]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
valueToIndex,
|
|
7
|
+
readAsNumber,
|
|
7
8
|
} = require('@ygracs/bsfoc-lib-js');
|
|
8
9
|
|
|
9
10
|
const {
|
|
11
|
+
isDateObject,
|
|
10
12
|
convDTValueToISO8601,
|
|
11
13
|
convDTValueToXMLTV, convXMLTVToDTValue,
|
|
12
14
|
convDTValueToDateString,
|
|
13
15
|
tryDTValue,
|
|
14
16
|
} = require('@ygracs/dtf-lib-js');
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
const {
|
|
19
|
+
_getXmlChildElementParam,
|
|
20
|
+
} = require('./xml-base');
|
|
17
21
|
|
|
18
|
-
// === module
|
|
22
|
+
// === module inner block ===
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
*
|
|
24
|
+
/**
|
|
25
|
+
* @param {?object} obj - element
|
|
26
|
+
* @param {object} [parseOptions] - parser options
|
|
27
|
+
* @returns {number}
|
|
28
|
+
* @inner
|
|
22
29
|
*/
|
|
30
|
+
function _getDTSTypeValueForXObj(obj, parseOptions) {
|
|
31
|
+
const result = valueToIndex(
|
|
32
|
+
_getXmlChildElementParam(obj, 'value', parseOptions)
|
|
33
|
+
);
|
|
34
|
+
return checkDTSysID(result) ? result : 0; //-1; // // TODO: [?]
|
|
35
|
+
};
|
|
36
|
+
module.exports._getDTSTypeValueForXObj = _getDTSTypeValueForXObj;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param {?object} obj - element
|
|
41
|
+
* @param {object} [parseOptions] - parser options
|
|
42
|
+
* @returns {number}
|
|
43
|
+
* @inner
|
|
44
|
+
*/
|
|
45
|
+
function _getTZSrcValueFromXObj(obj, parseOptions) {
|
|
46
|
+
return readAsNumber(_getXmlChildElementParam(obj, 'value', parseOptions));
|
|
47
|
+
};
|
|
48
|
+
module.exports._getTZSrcValueFromXObj = _getTZSrcValueFromXObj;
|
|
49
|
+
|
|
50
|
+
// === module main block ===
|
|
23
51
|
|
|
24
52
|
const def_dts_param = [
|
|
25
53
|
'default', 'iso8601', 'xmltv', 'timestamp', 'utc',
|
|
26
54
|
];
|
|
27
55
|
|
|
28
|
-
/***
|
|
29
|
-
* (* function definitions *)
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
56
|
/**
|
|
33
57
|
* Checks if a given value is a valid dtstype ID
|
|
34
58
|
* @function chkDTSysID
|
|
35
|
-
* @param {
|
|
59
|
+
* @param {number|string} value - value to verify
|
|
36
60
|
* @returns {boolean}
|
|
61
|
+
* @deprecated
|
|
62
|
+
* @todo \[since `v0.0.25`] deprecated. Use {@link checkDTSysID} instead
|
|
37
63
|
*/
|
|
38
64
|
function chkDTSysID(value) {
|
|
39
65
|
const _value = valueToIndex(value);
|
|
40
66
|
return _value !== -1 && def_dts_param[_value] ? true : false;
|
|
41
67
|
};
|
|
68
|
+
module.exports.chkDTSysID = chkDTSysID;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Checks if a given value is a valid dtstype ID
|
|
72
|
+
* @function checkDTSysID
|
|
73
|
+
* @param {number|string} value - value to verify
|
|
74
|
+
* @returns {boolean}
|
|
75
|
+
*/
|
|
76
|
+
function checkDTSysID(value) {
|
|
77
|
+
const _value = valueToIndex(value);
|
|
78
|
+
return _value !== -1 && def_dts_param[_value] ? true : false;
|
|
79
|
+
};
|
|
80
|
+
module.exports.checkDTSysID = checkDTSysID;
|
|
42
81
|
|
|
43
82
|
/**
|
|
44
83
|
* Returns a dtstype name by a given dtstype ID
|
|
45
84
|
* @function getDTSysName
|
|
46
|
-
* @param {
|
|
85
|
+
* @param {number|string} value - DTS-type identifier
|
|
47
86
|
* @returns {string}
|
|
48
87
|
*/
|
|
49
88
|
function getDTSysName(value) {
|
|
50
89
|
let result = 'undefined';
|
|
51
|
-
if (
|
|
90
|
+
if (checkDTSysID(value)) {
|
|
52
91
|
result = def_dts_param[Number(value)];
|
|
53
92
|
};
|
|
54
93
|
return result;
|
|
55
94
|
};
|
|
95
|
+
module.exports.getDTSysName = getDTSysName;
|
|
56
96
|
|
|
57
97
|
/**
|
|
58
98
|
* A 'DTS'-type descriptor
|
|
59
|
-
* @typedef {Object}
|
|
99
|
+
* @typedef {Object} IDTSysDescr
|
|
60
100
|
* @property {number} index - dtstype ID
|
|
61
101
|
* @property {string} name - dtstype name
|
|
62
102
|
*/
|
|
103
|
+
/**
|
|
104
|
+
* A virtual constant meant for support jsdoc notation:
|
|
105
|
+
* @type {IDTSysDescr}
|
|
106
|
+
*/
|
|
107
|
+
module.exports.IDTSysDescr = { index: 0, name: '' };
|
|
63
108
|
|
|
64
109
|
/**
|
|
65
110
|
* Returns a dtstype description for a given dtstype ID
|
|
66
111
|
* @function getDTSysDescr
|
|
67
|
-
* @param {
|
|
68
|
-
* @returns {
|
|
112
|
+
* @param {number|string} value - DTS-type identifier
|
|
113
|
+
* @returns {IDTSysDescr}
|
|
69
114
|
*/
|
|
70
115
|
function getDTSysDescr(value) {
|
|
71
116
|
let index = valueToIndex(value);
|
|
@@ -82,13 +127,14 @@ function getDTSysDescr(value) {
|
|
|
82
127
|
};
|
|
83
128
|
return { index, name };
|
|
84
129
|
};
|
|
130
|
+
module.exports.getDTSysDescr = getDTSysDescr;
|
|
85
131
|
|
|
86
132
|
/**
|
|
87
133
|
* Tries to convert a given string to timestamp
|
|
88
134
|
* @function convStringToDTValue
|
|
89
135
|
* @param {string} value - some value
|
|
90
|
-
* @param {
|
|
91
|
-
* @param {
|
|
136
|
+
* @param {number|string} [dts_id=0] - DTS-type identifier
|
|
137
|
+
* @param {number|string} [tz] - <*reserved*>
|
|
92
138
|
* @returns {number}
|
|
93
139
|
* @todo check TZ
|
|
94
140
|
*/
|
|
@@ -118,8 +164,8 @@ function convStringToDTValue(value, dts_id = 0, tz) {
|
|
|
118
164
|
case 'xmltv': {
|
|
119
165
|
// TODO: check TZ
|
|
120
166
|
//console.log('convStringToDTValue => dtstype:[xmltv]');
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
167
|
+
const dt = convXMLTVToDTValue(value, true);
|
|
168
|
+
if (dt !== null) result = isDateObject(dt) ? dt.getTime() : dt;
|
|
123
169
|
//console.log('convStringToDTValue => value:['+value+']');
|
|
124
170
|
//console.log('convStringToDTValue => result:['+result+']');
|
|
125
171
|
break;
|
|
@@ -148,13 +194,14 @@ function convStringToDTValue(value, dts_id = 0, tz) {
|
|
|
148
194
|
};
|
|
149
195
|
return result;
|
|
150
196
|
};
|
|
197
|
+
module.exports.convStringToDTValue = convStringToDTValue;
|
|
151
198
|
|
|
152
199
|
/**
|
|
153
200
|
* Tries to convert a given value to its string representation
|
|
154
201
|
* @function convDTValueToString
|
|
155
|
-
* @param {
|
|
156
|
-
* @param {
|
|
157
|
-
* @param {
|
|
202
|
+
* @param {number|string|Date} value - some value
|
|
203
|
+
* @param {number|string} [dts_id=0] - DTS-type identifier
|
|
204
|
+
* @param {number|string} [tz] - <*reserved*>
|
|
158
205
|
* @returns {string}
|
|
159
206
|
* @todo check TZ
|
|
160
207
|
*/
|
|
@@ -163,13 +210,13 @@ function convDTValueToString(value, dts_id, tz) {
|
|
|
163
210
|
let dt_val = isSucceed && dtValue != null ? dtValue.getTime() : new Date(0);
|
|
164
211
|
let result = '';
|
|
165
212
|
let dtstype = valueToIndex(dts_id);
|
|
166
|
-
if (!
|
|
213
|
+
if (!checkDTSysID(dtstype)) dtstype = 0;
|
|
167
214
|
switch (getDTSysName(dtstype)) {
|
|
168
215
|
case 'default': {
|
|
169
216
|
// TODO: check TZ
|
|
170
217
|
//console.log('convDTValueToString => dtstype:[default]');
|
|
171
218
|
result = convDTValueToDateString(dt_val, {
|
|
172
|
-
src_in_utc: false,
|
|
219
|
+
//src_in_utc: false,
|
|
173
220
|
});
|
|
174
221
|
//console.log('convDTValueToString => value:['+value+']');
|
|
175
222
|
//console.log('convDTValueToString => result:['+result+']');
|
|
@@ -179,9 +226,7 @@ function convDTValueToString(value, dts_id, tz) {
|
|
|
179
226
|
// TODO: check TZ
|
|
180
227
|
//console.log('convDTValueToString => dtstype:[iso8601]');
|
|
181
228
|
result = convDTValueToISO8601(dt_val, {
|
|
182
|
-
//use_bs_format: false,
|
|
183
229
|
useBaseFormat: false,
|
|
184
|
-
src_in_utc: false,
|
|
185
230
|
});
|
|
186
231
|
//console.log('convDTValueToString => value:['+value+']');
|
|
187
232
|
//console.log('convDTValueToString => result:['+result+']');
|
|
@@ -190,9 +235,7 @@ function convDTValueToString(value, dts_id, tz) {
|
|
|
190
235
|
case 'xmltv': {
|
|
191
236
|
// TODO: check TZ
|
|
192
237
|
//console.log('convDTValueToString => dtstype:[xmltv]');
|
|
193
|
-
result = convDTValueToXMLTV(dt_val, {
|
|
194
|
-
src_in_utc: false,
|
|
195
|
-
});
|
|
238
|
+
result = convDTValueToXMLTV(dt_val, {});
|
|
196
239
|
//console.log('convDTValueToString => value:['+value+']');
|
|
197
240
|
//console.log('convDTValueToString => result:['+result+']');
|
|
198
241
|
break;
|
|
@@ -209,16 +252,4 @@ function convDTValueToString(value, dts_id, tz) {
|
|
|
209
252
|
};
|
|
210
253
|
return result;
|
|
211
254
|
};
|
|
212
|
-
|
|
213
|
-
/***
|
|
214
|
-
* (* class definitions *)
|
|
215
|
-
*/
|
|
216
|
-
|
|
217
|
-
// === module exports block ===
|
|
218
|
-
|
|
219
|
-
exports.chkDTSysID = chkDTSysID;
|
|
220
|
-
exports.checkDTSysID = chkDTSysID;
|
|
221
|
-
exports.getDTSysName = getDTSysName;
|
|
222
|
-
exports.getDTSysDescr = getDTSysDescr;
|
|
223
|
-
exports.convStringToDTValue = convStringToDTValue;
|
|
224
|
-
exports.convDTValueToString = convDTValueToString;
|
|
255
|
+
module.exports.convDTValueToString = convDTValueToString;
|