Skip to content

Commit

Permalink
Merge pull request #180 from Digital-Engineering/development
Browse files Browse the repository at this point in the history
fixed unix time
  • Loading branch information
DnOberon authored and GitHub Enterprise committed Jan 11, 2023
2 parents d9fb2c0 + 575ebdf commit 25841bf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
7 changes: 3 additions & 4 deletions AdminWebApp/src/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
21 changes: 19 additions & 2 deletions src/domain_objects/data_warehouse/etl/type_transformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`});
Expand Down
2 changes: 2 additions & 0 deletions src/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '[email protected]';
Expand Down

0 comments on commit 25841bf

Please sign in to comment.