import { common } from '@kit.AbilityKit';

/**
 * Retrieves the context from AppStorage.
 * @returns common.UIAbilityContext
 * */
export function meowContext(): common.UIAbilityContext {
  return AppStorage.get('context') as common.UIAbilityContext;
}

export function parseTimestamp(timestamp: number, format = 'yyyy-MM-dd HH:mm') {  const date = new Date(timestamp);

  const year = date.getFullYear().toString();
  const month = (date.getMonth() + 1).toString().padStart(2, '0');
  const day = date.getDate().toString().padStart(2, '0');
  const hours = (date.getHours() + 1).toString().padStart(2, '0');
  const minutes = date.getMinutes().toString().padStart(2, '0');

  // 根据格式返回对应字符串
  return format
    .replace('yyyy', year)
    .replace('MM', month)
    .replace('dd', day)
    .replace('HH', hours)
    .replace('mm', minutes)
}
