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>
|
||||
</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">
|
||||
<a ng-click="restoreCostFile(costfile)"
|
||||
class="btn btn-danger btn-rounded btn-xs">{{'SETTING.RESTORE' | translate}}</a>
|
||||
|
|
|
@ -274,7 +274,7 @@ Result
|
|||
| id | integer | Cost File ID |
|
||||
| file_name | string | Cost File name |
|
||||
| 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) |
|
||||
| file_object | BLOB | Cost File Object |
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import json
|
|||
import mysql.connector
|
||||
import config
|
||||
import uuid
|
||||
from datetime import datetime, timezone
|
||||
from datetime import datetime, timezone, timedelta
|
||||
import os
|
||||
from core.userlogger import user_logger
|
||||
|
||||
|
@ -31,15 +31,18 @@ class CostFileCollection:
|
|||
cursor.close()
|
||||
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()
|
||||
if rows is not None and len(rows) > 0:
|
||||
for row in rows:
|
||||
upload_datetime = row[3]
|
||||
upload_datetime = upload_datetime.replace(tzinfo=timezone.utc)
|
||||
upload_datetime_local = row[3].replace(tzinfo=timezone.utc) + timedelta(minutes=timezone_offset)
|
||||
meta_result = {"id": row[0],
|
||||
"file_name": row[1],
|
||||
"uuid": row[2],
|
||||
"upload_datetime": upload_datetime.timestamp() * 1000,
|
||||
"upload_datetime": upload_datetime_local.strftime('%Y-%m-%dT%H:%M:%S'),
|
||||
"status": row[4]}
|
||||
result.append(meta_result)
|
||||
|
||||
|
@ -172,14 +175,15 @@ class CostFileItem:
|
|||
if row is None:
|
||||
raise falcon.HTTPError(falcon.HTTP_404, title='API.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 = upload_datetime.replace(tzinfo=timezone.utc)
|
||||
|
||||
upload_datetime_local = row[3].replace(tzinfo=timezone.utc) + timedelta(minutes=timezone_offset)
|
||||
result = {"id": row[0],
|
||||
"file_name": row[1],
|
||||
"uuid": row[2],
|
||||
"upload_datetime": upload_datetime.timestamp() * 1000,
|
||||
"upload_datetime": upload_datetime_local.strftime('%Y-%m-%dT%H:%M:%S'),
|
||||
"status": row[4]}
|
||||
resp.body = json.dumps(result)
|
||||
|
||||
|
|
Loading…
Reference in New Issue