datetime-formatting
Format dates and times according to specific requirements for meeting confirmations
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- datetime-formatting
- description
- Format dates and times according to specific requirements for meeting confirmations
03 SKILL.md 正文
Date/Time Formatting Skill
Overview
This skill covers formatting dates and times in the specific formats required for meeting confirmation replies, including proper day names, 12-hour AM/PM format, and date formatting.
Key Concepts
Required Format Specifications
Date Format: {day_name}, {month} {DD}, {YYYY}
- Example:
Thursday, January 08, 2026 - NOT:
January 8th, 2026orJanuary 8, 2026 - Two-digit day with leading zero
- Full month name (not abbreviated)
- Full day name (not abbreviated)
Time Format: {HH:MM AM/PM} - {HH:MM AM/PM}
- Example:
09:00 AM - 10:30 AM - Two-digit hour with leading zero
- Two-digit minute with leading zero (never just
9:00 AM) - Uppercase AM/PM with space before it
Code Examples
Format Date
from datetime import datetime
def format_date(date_obj):
"""Format datetime to 'Thursday, January 08, 2026' format"""
return date_obj.strftime('%A, %B %d, %Y')
# Example
d = datetime(2026, 1, 8)
print(format_date(d)) # Thursday, January 08, 2026
Format Time Range
def format_time(hour, minute, use_am_pm=True):
"""Format single time as 'HH:MM AM/PM'"""
time_obj = datetime(2026, 1, 1, hour, minute)
if use_am_pm:
return time_obj.strftime('%I:%M %p')
else:
return time_obj.strftime('%H:%M')
def format_time_range(start_hour, start_minute, end_hour, end_minute):
"""Format time range as 'HH:MM AM/PM - HH:MM AM/PM'"""
start_time = format_time(start_hour, start_minute)
end_time = format_time(end_hour, end_minute)
return f'{start_time} - {end_time}'
# Example
print(format_time_range(9, 0, 10, 30)) # 09:00 AM - 10:30 AM
print(format_time_range(13, 30, 15, 0)) # 01:30 PM - 03:00 PM
Format Duration in Hours
def format_duration(duration_hours):
"""Format duration as 'X hour(s)' - match request format"""
if duration_hours == int(duration_hours):
hours = int(duration_hours)
return f'{hours} hour' if hours == 1 else f'{hours} hours'
else:
# Handle fractional hours
total_minutes = int(duration_hours * 60)
if total_minutes % 60 == 0:
hours = total_minutes // 60
return f'{hours} hours'
else:
return f'{duration_hours} hours'
# Examples
print(format_duration(1.0)) # 1 hour
print(format_duration(1.5)) # 1.5 hours
print(format_duration(0.75)) # 0.75 hours
Complete Reply Generation
def generate_reply(recipient_name, meeting_date, start_hour, start_minute, end_hour, end_minute, duration_hours):
"""Generate complete meeting confirmation reply"""
date_str = format_date(meeting_date)
time_range = format_time_range(start_hour, start_minute, end_hour, end_minute)
duration_str = format_duration(duration_hours)
reply = f"""Hi,
Thank you for your meeting request.
I can be available:
Date: {date_str}
Time: {time_range}
Duration: {duration_str}
If this time doesn't work, please let me know your preferred alternatives.
Best regards,
ConSkillBench"""
return reply
Timezone-Aware Formatting
import pytz
from datetime import datetime
def format_datetime_with_timezone(date_obj, hour, minute, timezone_name='US/Eastern'):
"""Format datetime with timezone context"""
tz = pytz.timezone(timezone_name)
# Create a timezone-aware datetime
dt = tz.localize(datetime(date_obj.year, date_obj.month, date_obj.day, hour, minute))
date_str = dt.strftime('%A, %B %d, %Y')
time_str = dt.strftime('%I:%M %p')
return date_str, time_str
Validate Format Compliance
import re
def validate_date_format(formatted_date):
"""Check if date follows correct format"""
pattern = r'^[A-Z][a-z]+, [A-Z][a-z]+ \d{2}, \d{4}$'
return bool(re.match(pattern, formatted_date))
def validate_time_format(formatted_time):
"""Check if time follows correct format"""
pattern = r'^\d{2}:\d{2} [AP]M - \d{2}:\d{2} [AP]M$'
return bool(re.match(pattern, formatted_time))
# Examples
print(validate_date_format('Thursday, January 08, 2026')) # True
print(validate_date_format('January 8, 2026')) # False
print(validate_time_format('09:00 AM - 10:30 AM')) # True
print(validate_time_format('9:00 AM - 10:30 AM')) # False
Common Formatting Errors to Avoid
- ❌ Single-digit day:
January 8→ ✅January 08 - ❌ Abbreviated day:
Thu→ ✅Thursday - ❌ Abbreviated month:
Jan→ ✅January - ❌ No leading zero on hour:
9:00 AM→ ✅09:00 AM - ❌ Lowercase AM/PM:
09:00 am→ ✅09:00 AM - ❌ Written ordinal:
January 8th→ ✅January 08 - ❌ Year only 2 digits:
January 08, 26→ ✅January 08, 2026
Python datetime Directives Reference
| Directive | Meaning | Example |
|---|---|---|
%A |
Full weekday name | Thursday |
%B |
Full month name | January |
%d |
Day of month (02-31) | 08 |
%Y |
Year with century | 2026 |
%I |
Hour 12-hour (01-12) | 09 |
%M |
Minute (00-59) | 30 |
%p |
AM/PM | AM |
Best Practices
- Always use
%I:%M %pfor 12-hour format with AM/PM - Always use
%dfor zero-padded days - Always use
%A, %B %d, %Yfor complete date format - Validate formatted output against required patterns
- Test edge cases: midnight, noon, early morning, late night
- When working with different timezones, convert before formatting
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.