changed cost file upload datetime formatter from timestamp to strftime
parent
74de652736
commit
6962c65aab
|
@ -120,8 +120,7 @@
|
||||||
download="{{costfile.file_name}}">{{ costfile.file_name }}</a>
|
download="{{costfile.file_name}}">{{ costfile.file_name }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center">{{ costfile.status }}</td>
|
<td class="text-center">{{ costfile.status }}</td>
|
||||||
<td class="text-center">{{ costfile.upload_datetime | date:'yyyy-MM-dd HH:mm'}}</td>
|
<td class="text-center">{{ costfile.upload_datetime}}</td>
|
||||||
|
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<a ng-click="restoreCostFile(costfile)"
|
<a ng-click="restoreCostFile(costfile)"
|
||||||
class="btn btn-danger btn-rounded btn-xs">{{'SETTING.RESTORE' | translate}}</a>
|
class="btn btn-danger btn-rounded btn-xs">{{'SETTING.RESTORE' | translate}}</a>
|
||||||
|
|
|
@ -274,7 +274,7 @@ Result
|
||||||
| id | integer | Cost File ID |
|
| id | integer | Cost File ID |
|
||||||
| file_name | string | Cost File name |
|
| file_name | string | Cost File name |
|
||||||
| uuid | string | Cost File UUID |
|
| uuid | string | Cost File UUID |
|
||||||
| upload_datetime | float | the number of milliseconds since January 1, 1970, 00:00:00, universal time |
|
| upload_datetime | string | Upload Datetime in Local Timezone |
|
||||||
| status | string | Cost File processing status (new, done, error) |
|
| status | string | Cost File processing status (new, done, error) |
|
||||||
| file_object | BLOB | Cost File Object |
|
| file_object | BLOB | Cost File Object |
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import json
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
import config
|
import config
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone, timedelta
|
||||||
import os
|
import os
|
||||||
from core.userlogger import user_logger
|
from core.userlogger import user_logger
|
||||||
|
|
||||||
|
@ -31,15 +31,18 @@ class CostFileCollection:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
|
|
||||||
|
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6])
|
||||||
|
if config.utc_offset[0] == '-':
|
||||||
|
timezone_offset = -timezone_offset
|
||||||
|
|
||||||
result = list()
|
result = list()
|
||||||
if rows is not None and len(rows) > 0:
|
if rows is not None and len(rows) > 0:
|
||||||
for row in rows:
|
for row in rows:
|
||||||
upload_datetime = row[3]
|
upload_datetime_local = row[3].replace(tzinfo=timezone.utc) + timedelta(minutes=timezone_offset)
|
||||||
upload_datetime = upload_datetime.replace(tzinfo=timezone.utc)
|
|
||||||
meta_result = {"id": row[0],
|
meta_result = {"id": row[0],
|
||||||
"file_name": row[1],
|
"file_name": row[1],
|
||||||
"uuid": row[2],
|
"uuid": row[2],
|
||||||
"upload_datetime": upload_datetime.timestamp() * 1000,
|
"upload_datetime": upload_datetime_local.strftime('%Y-%m-%dT%H:%M:%S'),
|
||||||
"status": row[4]}
|
"status": row[4]}
|
||||||
result.append(meta_result)
|
result.append(meta_result)
|
||||||
|
|
||||||
|
@ -172,14 +175,15 @@ class CostFileItem:
|
||||||
if row is None:
|
if row is None:
|
||||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND',
|
raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND',
|
||||||
description='API.COST_FILE_NOT_FOUND')
|
description='API.COST_FILE_NOT_FOUND')
|
||||||
|
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6])
|
||||||
|
if config.utc_offset[0] == '-':
|
||||||
|
timezone_offset = -timezone_offset
|
||||||
|
|
||||||
upload_datetime = row[3]
|
upload_datetime_local = row[3].replace(tzinfo=timezone.utc) + timedelta(minutes=timezone_offset)
|
||||||
upload_datetime = upload_datetime.replace(tzinfo=timezone.utc)
|
|
||||||
|
|
||||||
result = {"id": row[0],
|
result = {"id": row[0],
|
||||||
"file_name": row[1],
|
"file_name": row[1],
|
||||||
"uuid": row[2],
|
"uuid": row[2],
|
||||||
"upload_datetime": upload_datetime.timestamp() * 1000,
|
"upload_datetime": upload_datetime_local.strftime('%Y-%m-%dT%H:%M:%S'),
|
||||||
"status": row[4]}
|
"status": row[4]}
|
||||||
resp.body = json.dumps(result)
|
resp.body = json.dumps(result)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue