Skip to content

Commit

Permalink
Removed luxon DateTime. Replaced with plan Date.
Browse files Browse the repository at this point in the history
Added parsing of CommercialInformation creationTimestamp from string to Date.
  • Loading branch information
dobromyslov committed Aug 12, 2020
1 parent 2fb5e61 commit 3f43886
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 18 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ import {createReadStream} from "fs";
// Create parser for CommerceML catalog import file
const catalogImportParser = new CommerceMlImportParser();

// Define handler for commercial information header
catalogImportParser.onCommercialInformation(commercialInformation => {
console.log('commercialInformation', JSON.stringify(commercialInformation));
});

// Define handler for classifier XML block
catalogImportParser.onClassifier(classifier => {
console.log('classifier', JSON.stringify(classifier));
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/jasmine": "^3.5.12",
"@types/luxon": "^1.24.3",
"@types/node": "^13.11.0",
"@types/sax": "^1.2.1",
"@typescript-eslint/eslint-plugin": "^3.9.0",
Expand Down
4 changes: 4 additions & 0 deletions spec/example.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import {createReadStream} from "fs";
describe('CommerceMlParser', () => {
it('is ok', async () => {
const catalogImportParser = new CommerceMlImportParser();
catalogImportParser.onCommercialInformation(commercialInformation => {
console.log('commercialInformation', JSON.stringify(commercialInformation));
});

catalogImportParser.onClassifier(classifier => {
console.log('classifier', JSON.stringify(classifier));
});
Expand Down
2 changes: 1 addition & 1 deletion src/import-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class CommerceMlImportParser extends CommerceMlAbstractParser {
this.parser.on('commercialInformation', (data: any) => {
const commercialInformation: CommercialInformation = {
schemaVersion: data.КоммерческаяИнформация._ВерсияСхемы,
creationTimestamp: data.КоммерческаяИнформация._ДатаФормирования
creationTimestamp: new Date(data.КоммерческаяИнформация._ДатаФормирования)
};

callback(commercialInformation);
Expand Down
2 changes: 1 addition & 1 deletion src/offers-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class CommerceMlOffersParser extends CommerceMlAbstractParser {
this.parser.on('commercialInformation', (data: any) => {
const commercialInformation: CommercialInformation = {
schemaVersion: data.КоммерческаяИнформация._ВерсияСхемы,
creationTimestamp: data.КоммерческаяИнформация._ДатаФормирования
creationTimestamp: new Date(data.КоммерческаяИнформация._ДатаФормирования)
};

callback(commercialInformation);
Expand Down
2 changes: 1 addition & 1 deletion src/orders-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class OrdersParser extends CommerceMlAbstractParser {
this.parser.on('commercialInformation', (data: any) => {
const commercialInformation: CommercialInformation = {
schemaVersion: data.КоммерческаяИнформация._ВерсияСхемы,
creationTimestamp: data.КоммерческаяИнформация._ДатаФормирования
creationTimestamp: new Date(data.КоммерческаяИнформация._ДатаФормирования)
};

callback(commercialInformation);
Expand Down
26 changes: 12 additions & 14 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {DateTime} from 'luxon';

/**
* CommerceML 2.10.
* 1.1.50 Группа.
Expand Down Expand Up @@ -458,7 +456,7 @@ export interface PersonInfo {
*
* Дата рождения.
*/
birthday?: DateTime;
birthday?: Date;

/**
* Элемент: МестоРождения
Expand Down Expand Up @@ -541,7 +539,7 @@ export interface IdentityDocument {
*
* Когда выдан.
*/
issueDate: DateTime;
issueDate: Date;

/**
* Элемент: КемВыдан
Expand Down Expand Up @@ -818,7 +816,7 @@ export interface CompanyInfo {
*
* Дата регистрации организации.
*/
registrationDate?: DateTime;
registrationDate?: Date;

/**
* Элемент: ЮридическийАдрес
Expand Down Expand Up @@ -2141,7 +2139,7 @@ export interface OffersPackage {
*
* Дата (включительно), с которой начинает действовать предложение.
*/
validFrom?: DateTime;
validFrom?: Date;

/**
* Элемент: ДействительноДо
Expand All @@ -2150,7 +2148,7 @@ export interface OffersPackage {
*
* Дата (включительно), с которой заканчивает действовать предложение.
*/
validUntil?: DateTime;
validUntil?: Date;

/**
* Элемент: Описание
Expand Down Expand Up @@ -2480,7 +2478,7 @@ export interface ChildDocument {
*
* Дата документа.
*/
date: DateTime;
date: Date;

/**
* Элемент: ХозОперация
Expand Down Expand Up @@ -2536,7 +2534,7 @@ export interface ChildDocument {
*
* Время документа.
*/
time?: DateTime;
time?: Date;

/**
* Элемент: СрокПлатежа
Expand All @@ -2545,7 +2543,7 @@ export interface ChildDocument {
*
* Срок платежа.
*/
paymentTerm?: DateTime;
paymentTerm?: Date;

/**
* Элемент: Комментарий
Expand Down Expand Up @@ -2666,7 +2664,7 @@ export interface Document {
*
* Дата документа
*/
date: DateTime;
date: Date;

/**
* Элемент: ХозОперация
Expand Down Expand Up @@ -2732,7 +2730,7 @@ export interface Document {
*
* Время документа.
*/
time?: DateTime;
time?: Date;

/**
* Элемент: СрокПлатежа
Expand All @@ -2741,7 +2739,7 @@ export interface Document {
*
* Срок платежа.
*/
paymentTerm?: DateTime;
paymentTerm?: Date;

/**
* Элемент: Комментарий
Expand Down Expand Up @@ -2852,7 +2850,7 @@ export interface CommercialInformation {
*
* Дата формирования ЭД
*/
creationTimestamp: DateTime;
creationTimestamp: Date;

/**
* Элемент: Классификатор
Expand Down

0 comments on commit 3f43886

Please sign in to comment.