feat(date): enhance date formatting and timezone handling
- Update formatDateTime function to handle timezone-aware date strings directly. - Introduce utcToBeijingISOString function for consistent Beijing time formatting in ISO string. - Modify BidsService to utilize the new utcToBeijingISOString for date conversions. - Add unit tests for AuthGuard to validate API key authentication and access control. - Create end-to-end tests for API key handling in various scenarios. - Update .gitignore to exclude 'qingyun' directory. - Add environment configuration for production settings in .env.production. - Include Tailwind CSS setup in the uni-app version for styling.
This commit is contained in:
@@ -28,6 +28,17 @@ export function formatDate(dateStr: string | null | undefined): string {
|
||||
*/
|
||||
export function formatDateTime(dateStr: string | null | undefined): string {
|
||||
if (!dateStr) return '-'
|
||||
|
||||
// 如果时间字符串已经包含时区信息(如 +08:00),说明已经是正确的北京时间
|
||||
// 直接从字符串中提取日期和时间部分,避免时区转换问题
|
||||
const timezoneMatch = dateStr.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}):\d{2}(?:\.\d{3})?[+-]\d{2}:\d{2}$/)
|
||||
|
||||
if (timezoneMatch) {
|
||||
// 时间字符串已包含时区,直接提取日期和时间
|
||||
return `${timezoneMatch[1]} ${timezoneMatch[2]}`
|
||||
}
|
||||
|
||||
// 没有时区信息或格式不匹配,使用 Date 对象解析并转换
|
||||
const date = new Date(dateStr)
|
||||
if (isNaN(date.getTime())) return '-'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user