export function getDateComponents(date, ...components) {
	const year = date.getFullYear();
	const month = String(date.getMonth() + 1).padStart(2, '0');
	const day = String(date.getDate()).padStart(2, '0');
	const hour = String(date.getHours()).padStart(2, '0');
	const minute = String(date.getMinutes()).padStart(2, '0');
	const second = String(date.getSeconds()).padStart(2, '0');
	const week_cn = ["日", "一", "二", "三", "四", "五", "六"][date.getDay()];
	const weekday_cn = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"][date.getDay()];
	const weekday_cnx = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"][date.getDay()];
	const week_en = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][date.getDay()];

	const result = {};

	for (const component of components) {
		switch (component.toLowerCase()) {
			case 'yyyy-mm-dd':
			case 'date':
				result['date'] = `${year}-${month}-${day}`;
				break;
			case 'yyyy-mm-dd hh:mm:ss':
			case 'datetime':
				result['datetime'] = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
				break;
			case 'monthday':
				result['monthday'] = `${month}-${day}`;
				break;
			case 'monthday_cn':
				result['monthday_cn'] = `${month}月-${day}日`;
				break;
			case 'hh:mm:ss':
			case 'time':
				result['time'] = `${hour}:${minute}:${second}`;
				break;
			case 'week_cn':
				result['week_cn'] = week_cn;
				break;
			case 'weekday_cn':
				result['weekday_cn'] = weekday_cn;
				break;
			case 'weekday_cnx':
				result['weekday_cnx'] = weekday_cnx;
				break;
			case 'week_en':
				result['week_en'] = week_en;
				break;
			default:
				break;
		}
	}

	return result;
}