import test from 'node:test'
import assert from 'node:assert/strict'
import { formatSkillDate, formatSkillDateTime, normalizeSkillTimestamps } from './skillTimestamp.js'

test('normalizes both created_at and updated_at from Unix seconds', () => {
  const skill = normalizeSkillTimestamps({
    created_at: 1784474849,
    updated_at: 1784474849,
  })

  assert.equal(skill.created_at, '2026-07-19T15:27:29.000Z')
  assert.equal(skill.updated_at, '2026-07-19T15:27:29.000Z')
})

test('formats skill timestamps in the Shanghai business timezone', () => {
  const iso = '2026-07-19T17:23:14.000Z'
  assert.equal(formatSkillDate(iso), '2026-07-20')
  assert.equal(formatSkillDateTime(iso), '2026-07-20 01:23:14')
  assert.equal(formatSkillDate(null), '—')
})
