mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-05-01 23:29:37 +08:00
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @file plugins/Sqlite/utils/transCharacter.ts
|
||||
* @description Sqlite 数据转换
|
||||
* @since Beta v0.3.9
|
||||
* @since Beta v0.6.0
|
||||
*/
|
||||
|
||||
import { timeToSecond } from "./transTime.js";
|
||||
import { timestampToDate } from "../../../utils/toolFunc.js";
|
||||
|
||||
/**
|
||||
* @description 将通过 api 获取到的深渊数据转换为数据库中的数据
|
||||
@@ -66,13 +66,13 @@ function transLevelData(data: TGApp.Game.Abyss.Level): TGApp.Sqlite.Abyss.Level
|
||||
|
||||
/**
|
||||
* @description 将通过 api 获取到的深渊数据转换为数据库中的数据
|
||||
* @since Alpha v0.2.0
|
||||
* @since Beta v0.6.0
|
||||
* @param {TGApp.Game.Abyss.Battle} data 深渊数据
|
||||
* @returns {TGApp.Sqlite.Abyss.Battle} 转换后的深渊数据
|
||||
*/
|
||||
function transBattleData(data: TGApp.Game.Abyss.Battle): TGApp.Sqlite.Abyss.Battle {
|
||||
return {
|
||||
time: timeToSecond(data.timestamp),
|
||||
time: timestampToDate(Number(data.timestamp) * 1000),
|
||||
characters: data.avatars.map((item) => {
|
||||
return {
|
||||
id: item.id,
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* @file plugins Sqlite utils transTime.ts
|
||||
* @description Sqlite 时间转换工具类
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description 将时间戳转换为时间字符串
|
||||
* @since Alpha v0.2.0
|
||||
* @param {string} timestamp 时间戳 (秒)
|
||||
* @returns {string} 时间字符串,格式为 YYYY-MM-DD HH:mm:ss
|
||||
*/
|
||||
export function timeToSecond(timestamp: string): string {
|
||||
const date = new Date(Number(timestamp) * 1000);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(date.getDate()).padStart(2, "0");
|
||||
const hour = String(date.getHours()).padStart(2, "0");
|
||||
const minute = String(date.getMinutes()).padStart(2, "0");
|
||||
const second = String(date.getSeconds()).padStart(2, "0");
|
||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||
}
|
||||
Reference in New Issue
Block a user