updated timezone/date handling for fields that dont require time data
This commit is contained in:
@@ -2,7 +2,7 @@ import { BatchPromotion, BatchPromotionMember } from "@app/shared/schemas/promot
|
||||
import { PromotionDetails, PromotionSummary } from "@app/shared/types/rank"
|
||||
import pool from "../../db";
|
||||
import { PagedData } from "@app/shared/types/pagination";
|
||||
import { toDateTime } from "@app/shared/utils/time";
|
||||
import { toDate, toDateIgnoreZone, toDateTime } from "@app/shared/utils/time";
|
||||
|
||||
export async function getAllRanks() {
|
||||
const rows = await pool.query(
|
||||
@@ -40,7 +40,7 @@ export async function batchInsertMemberRank(promos: BatchPromotionMember[], auth
|
||||
try {
|
||||
var con = await pool.getConnection();
|
||||
promos.forEach(p => {
|
||||
con.query(`CALL sp_update_member_rank(?, ?, ?, ?, ?, ?)`, [p.member_id, p.rank_id, author, author, "Rank Change", toDateTime(new Date(p.start_date))])
|
||||
con.query(`CALL sp_update_member_rank(?, ?, ?, ?, ?, ?)`, [p.member_id, p.rank_id, author, author, "Rank Change", toDateIgnoreZone(new Date(p.start_date))])
|
||||
});
|
||||
|
||||
con.commit();
|
||||
|
||||
@@ -3,12 +3,34 @@ export function toDateTime(date: Date): string {
|
||||
date = new Date(date);
|
||||
}
|
||||
// This produces a CST-local time because server runs in CST
|
||||
const year = date.getFullYear();
|
||||
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
||||
const day = date.getDate().toString().padStart(2, "0");
|
||||
const hour = date.getHours().toString().padStart(2, "0");
|
||||
const year = date.getFullYear();
|
||||
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
||||
const day = date.getDate().toString().padStart(2, "0");
|
||||
const hour = date.getHours().toString().padStart(2, "0");
|
||||
const minute = date.getMinutes().toString().padStart(2, "0");
|
||||
const second = date.getSeconds().toString().padStart(2, "0");
|
||||
|
||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||
}
|
||||
|
||||
export function toDateIgnoreZone(date: Date): string {
|
||||
if (typeof date === 'string') {
|
||||
date = new Date(date);
|
||||
}
|
||||
return date.toISOString().split('T')[0];
|
||||
}
|
||||
|
||||
export function toDate(date: Date): string {
|
||||
if (typeof date === 'string') {
|
||||
date = new Date(date);
|
||||
}
|
||||
console.log(date);
|
||||
// This produces a CST-local date because server runs in CST
|
||||
const year = date.getFullYear();
|
||||
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
||||
const day = date.getDate().toString().padStart(2, "0");
|
||||
let out = `${year}-${month}-${day}`;
|
||||
|
||||
console.log(out);
|
||||
return out;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ function filterRanks(query: string): Rank[] {
|
||||
r.name.toLowerCase().includes(q) ||
|
||||
r.short_name.toLowerCase().includes(q)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
allmembers.value = await getAllLightMembers()
|
||||
@@ -168,7 +168,8 @@ function setAllToday() {
|
||||
:display-value="id =>
|
||||
memberById.get(id)?.displayName ||
|
||||
memberById.get(id)?.username
|
||||
" @input="memberSearch = $event.target.value" />
|
||||
" @input="memberSearch = $event.target.value"
|
||||
/>
|
||||
</ComboboxAnchor>
|
||||
<ComboboxList>
|
||||
<ComboboxEmpty>No results</ComboboxEmpty>
|
||||
|
||||
Reference in New Issue
Block a user