We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/gvc2000/AgenteCidadaoMCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
date.ts•1.2 KiB
export function formatDate(date: Date | string): string {
const d = typeof date === 'string' ? new Date(date) : date;
return d.toISOString().split('T')[0];
}
export function parseDate(dateStr: string): Date {
return new Date(dateStr);
}
export function isValidDate(dateStr: string): boolean {
const regex = /^\d{4}-\d{2}-\d{2}$/;
if (!regex.test(dateStr)) return false;
const date = new Date(dateStr);
return date instanceof Date && !isNaN(date.getTime());
}
export function getCurrentYear(): number {
return new Date().getFullYear();
}
export function getCurrentMonth(): number {
return new Date().getMonth() + 1; // 1-based
}
export function formatBrazilianDate(date: Date | string): string {
const d = typeof date === 'string' ? new Date(date) : date;
return d.toLocaleDateString('pt-BR');
}
export function formatDateTime(date: Date | string): string {
const d = typeof date === 'string' ? new Date(date) : date;
return d.toLocaleDateString('pt-BR') + ' ' + d.toLocaleTimeString('pt-BR');
}
export function isDateInRange(date: string, start: string, end: string): boolean {
const d = new Date(date);
const s = new Date(start);
const e = new Date(end);
return d >= s && d <= e;
}