diff --git a/AdminWebApp/src/translations.ts b/AdminWebApp/src/translations.ts index cfed6a172..bc85a0f2d 100644 --- a/AdminWebApp/src/translations.ts +++ b/AdminWebApp/src/translations.ts @@ -105,7 +105,7 @@ export default { containerExport: 'Export Container', containerExportDescription: 'Export Container to File', containerImport: 'Import Container', - containerImportDescription: 'Import Container from File' + containerImportDescription: 'Import Container from File', }, containerExport: { pageTitle: 'Export Container to File', @@ -119,8 +119,7 @@ export default { }, containerImport: { pageTitle: 'Import Container from File', - pageDescription: - "Use this page to import your container and it's various parts from a file that was generated by a previous container export.", + pageDescription: "Use this page to import your container and it's various parts from a file that was generated by a previous container export.", importOntology: 'Ontology', importOntologyHelp: 'Imports a new ontology from the supplied container file.', importDataSources: 'Data Sources', @@ -983,7 +982,7 @@ export default { resultingTypes: 'Metatype/Metatype Relationship/Name', requiredField: 'Required Field', dateFormatString: 'Date Format String(blank for ISO)', - dateFormatStringHelp: 'Formatting your date/time', + dateFormatStringHelp: 'Formatting your date/time - if you do not include a timezone, we will assume UTC time.', selectNodeID: 'Target Node', selectNodeIDHelp: 'These fields allow you to select which node this time series data should be attached to.', nodeIDKey: 'Node ID Key', diff --git a/src/domain_objects/data_warehouse/etl/type_transformation.ts b/src/domain_objects/data_warehouse/etl/type_transformation.ts index 8498fe343..7491ac6cc 100644 --- a/src/domain_objects/data_warehouse/etl/type_transformation.ts +++ b/src/domain_objects/data_warehouse/etl/type_transformation.ts @@ -987,12 +987,29 @@ export default class TypeTransformation extends BaseDomainClass { // if it's a number we assume we're dealing with unix time if (typeof value === 'number') { - return new Conversion({original_value: value, converted_value: toDate(value).toISOString()}); + try { + let convertedDate = date_conversion_format ? parse(value.toString(), date_conversion_format, new Date()) : new Date(value); + + convertedDate = + date_conversion_format?.includes('x') || date_conversion_format?.includes('X') + ? convertedDate + : new Date((convertedDate as any) - convertedDate.getTimezoneOffset() * 60 * 1000); + + return new Conversion({original_value: value, converted_value: convertedDate.toISOString()}); + } catch (e) { + return new Conversion({original_value: value, errors: `unable to convert value to date using format string: ${e}`}); + } } if (typeof value === 'string') { try { - const convertedDate = date_conversion_format ? parse(value, date_conversion_format, new Date()) : new Date(value); + let convertedDate = date_conversion_format ? parse(value, date_conversion_format, new Date()) : new Date(value); + + convertedDate = + date_conversion_format?.includes('x') || date_conversion_format?.includes('X') + ? convertedDate + : new Date((convertedDate as any) - convertedDate.getTimezoneOffset() * 60 * 1000); + return new Conversion({original_value: value, converted_value: convertedDate.toISOString()}); } catch (e) { return new Conversion({original_value: value, errors: `unable to convert value to date using format string: ${e}`}); diff --git a/src/services/config.ts b/src/services/config.ts index 4a534aada..3226ccd38 100644 --- a/src/services/config.ts +++ b/src/services/config.ts @@ -116,12 +116,14 @@ export class Config { private readonly _cache_graphql: boolean; private readonly _cors_origins: string[] | string; + private readonly _tz: string; private constructor() { // Either assign a sane default of the env var is missing, or create your // own checks on process.env. There is most likely a more elegant way but // I like including sane defaults in the app itself vs. an env-sample file + this._tz = process.env.TZ || 'GMT'; this._project_dir = process.env.PROJECT_DIR || './dist'; this._root_address = process.env.ROOT_ADDRESS || 'http://localhost:8090'; this._email_address = process.env.EMAIL_ADDRESS || 'do+not+reply@deeplynx.org';