alihmaou commited on
Commit
ff0bda1
verified
1 Parent(s): b4bcead

Deploy tools/calendrier.py via Meta-MCP

Browse files
Files changed (1) hide show
  1. tools/calendrier.py +70 -0
tools/calendrier.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import json
3
+ from PIL import Image
4
+ import numpy as np
5
+
6
+ # --- User Defined Logic ---
7
+ import datetime
8
+
9
+ def calendrier(format: str) -> str:
10
+ """Return the current date formatted according to the requested style.
11
+
12
+ Args:
13
+ format (str): Desired output format. Accepted values are:
14
+ - "court": e.g. "25/11/2025"
15
+ - "long": e.g. "mardi 25 novembre 2025"
16
+ - "complet": e.g. "mardi 25 novembre 2025 脿 14h30"
17
+ - "iso": e.g. "2025-11-25"
18
+ - "us": e.g. "11/25/2025"
19
+
20
+ Returns:
21
+ str: The current date formatted as a string according to the selected format.
22
+
23
+ Raises:
24
+ ValueError: If an unsupported format string is provided.
25
+ """
26
+ now = datetime.datetime.now()
27
+ format = format.lower()
28
+
29
+ if format == "court":
30
+ return now.strftime("%d/%m/%Y")
31
+ elif format == "iso":
32
+ return now.strftime("%Y-%m-%d")
33
+ elif format == "us":
34
+ return now.strftime("%m/%d/%Y")
35
+ elif format in ("long", "complet"):
36
+ weekdays = ["lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"]
37
+ months = [
38
+ "janvier",
39
+ "f茅vrier",
40
+ "mars",
41
+ "avril",
42
+ "mai",
43
+ "juin",
44
+ "juillet",
45
+ "ao没t",
46
+ "septembre",
47
+ "octobre",
48
+ "novembre",
49
+ "d茅cembre",
50
+ ]
51
+ day_name = weekdays[now.weekday()]
52
+ month_name = months[now.month - 1]
53
+ base = f"{day_name} {now.day} {month_name} {now.year}"
54
+ if format == "complet":
55
+ return f"{base} 脿 {now.hour:02d}h{now.minute:02d}"
56
+ return base
57
+ else:
58
+ raise ValueError(
59
+ "Format non support茅. Utilisez 'court', 'long', 'complet', 'iso' ou 'us'."
60
+ )
61
+
62
+ # --- Interface Factory ---
63
+ def create_interface():
64
+ return gr.Interface(
65
+ fn=calendrier,
66
+ inputs=[gr.Textbox(label=k) for k in ['format']],
67
+ outputs=gr.Textbox(label="Date format茅e selon le param猫tre choisi"),
68
+ title="calendrier",
69
+ description="Auto-generated tool: calendrier"
70
+ )