Skip to content

Commit 3e31202

Browse files
Docs: Add missing methods to datetime, os, pathlib documentation
- datetime: Add datetime class methods, time methods, timezone class - pathlib: Add 25+ missing Path methods (touch, chmod, symlink, walk, etc.) - os: Add process/env functions, link operations, path helpers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1a6e61a commit 3e31202

3 files changed

Lines changed: 94 additions & 2 deletions

File tree

docs/stdlib/datetime.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,48 @@ The `datetime` module provides classes for manipulating dates and times.
2121
| Operation | Time | Space | Notes |
2222
|-----------|------|-------|-------|
2323
| `date.year`, `date.month`, `date.day` | O(1) | O(1) | Attribute access |
24-
| `date.weekday()` | O(1) | O(1) | Day of week (0-6) |
25-
| `date.isoweekday()` | O(1) | O(1) | Day of week (1-7) |
24+
| `date.today()` | O(1) | O(1) | Current local date |
25+
| `date.fromisoformat(s)` | O(n) | O(1) | Parse ISO format string |
26+
| `date.fromtimestamp(ts)` | O(1) | O(1) | From Unix timestamp |
27+
| `date.fromordinal(n)` | O(1) | O(1) | From proleptic Gregorian ordinal |
28+
| `date.fromisocalendar(y, w, d)` | O(1) | O(1) | From ISO year, week, day |
29+
| `date.weekday()` | O(1) | O(1) | Day of week (0=Mon, 6=Sun) |
30+
| `date.isoweekday()` | O(1) | O(1) | Day of week (1=Mon, 7=Sun) |
31+
| `date.isocalendar()` | O(1) | O(1) | Returns (year, week, weekday) |
2632
| `date.isoformat()` | O(1) | O(1) | ISO 8601 string |
33+
| `date.strftime(fmt)` | O(n) | O(n) | Format to string |
34+
| `date.ctime()` | O(1) | O(1) | C-style string |
35+
| `date.timetuple()` | O(1) | O(1) | time.struct_time |
36+
| `date.toordinal()` | O(1) | O(1) | Proleptic Gregorian ordinal |
2737
| `date.replace(year=...)` | O(1) | O(1) | Return new date |
2838

39+
## Datetime Operations
40+
41+
| Operation | Time | Space | Notes |
42+
|-----------|------|-------|-------|
43+
| `datetime.combine(date, time)` | O(1) | O(1) | Combine date and time objects |
44+
| `datetime.fromisoformat(s)` | O(n) | O(1) | Parse ISO format string |
45+
| `datetime.date()` | O(1) | O(1) | Extract date part |
46+
| `datetime.time()` | O(1) | O(1) | Extract time part (no tzinfo) |
47+
| `datetime.timetz()` | O(1) | O(1) | Extract time part (with tzinfo) |
48+
| `datetime.timestamp()` | O(1) | O(1) | Return POSIX timestamp |
49+
| `datetime.utctimetuple()` | O(1) | O(1) | UTC time.struct_time |
50+
| `datetime.dst()` | O(1) | O(1) | Daylight saving offset |
51+
| `datetime.tzname()` | O(1) | O(1) | Timezone name string |
52+
| `datetime.utcoffset()` | O(1) | O(1) | UTC offset as timedelta |
53+
2954
## Time Operations
3055

3156
| Operation | Time | Space | Notes |
3257
|-----------|------|-------|-------|
3358
| `time.hour`, `time.minute`, `time.second` | O(1) | O(1) | Attribute access |
59+
| `time.fromisoformat(s)` | O(n) | O(1) | Parse ISO format string |
3460
| `time.isoformat()` | O(1) | O(1) | ISO 8601 string |
61+
| `time.strftime(fmt)` | O(n) | O(n) | Format to string |
3562
| `time.replace(hour=...)` | O(1) | O(1) | Return new time |
63+
| `time.dst()` | O(1) | O(1) | Daylight saving offset |
64+
| `time.tzname()` | O(1) | O(1) | Timezone name string |
65+
| `time.utcoffset()` | O(1) | O(1) | UTC offset as timedelta |
3666

3767
## Timedelta Operations
3868

@@ -139,6 +169,17 @@ dates = [dt2, dt1, dt1 + timedelta(days=1)]
139169
sorted_dates = sorted(dates) # O(n log n)
140170
```
141171

172+
## Timezone Class
173+
174+
| Operation | Time | Space | Notes |
175+
|-----------|------|-------|-------|
176+
| `timezone(offset)` | O(1) | O(1) | Create fixed offset timezone |
177+
| `timezone.utc` | O(1) | O(1) | UTC timezone constant |
178+
| `tz.utcoffset(dt)` | O(1) | O(1) | Return offset from UTC |
179+
| `tz.tzname(dt)` | O(1) | O(1) | Return timezone name |
180+
| `tz.dst(dt)` | O(1) | O(1) | Return DST offset (always None for timezone) |
181+
| `tz.fromutc(dt)` | O(1) | O(1) | Convert UTC datetime to this timezone |
182+
142183
## Timezone Operations
143184

144185
```python

docs/stdlib/os.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,46 @@ The `os` module provides a way to use operating system-dependent functionality l
99
| `os.path.exists(path)` | O(1) | O(1) | Check if path exists |
1010
| `os.path.isfile(path)` | O(1) | O(1) | Check if file |
1111
| `os.path.isdir(path)` | O(1) | O(1) | Check if directory |
12+
| `os.path.islink(path)` | O(1) | O(1) | Check if symlink |
13+
| `os.path.getsize(path)` | O(1) | O(1) | Get file size in bytes |
14+
| `os.path.getatime(path)` | O(1) | O(1) | Get last access time |
15+
| `os.path.getmtime(path)` | O(1) | O(1) | Get last modification time |
16+
| `os.path.getctime(path)` | O(1) | O(1) | Get creation/metadata change time |
1217
| `os.listdir(path)` | O(n) | O(n) | List directory contents |
1318
| `os.scandir(path)` | O(n) | O(1) | Lazy directory iterator |
1419
| `os.walk(path)` | O(n) | O(d) | n = total entries, d = max depth (call stack + pending dirs) |
1520
| `os.stat(path)` | O(1) | O(1) | Get file statistics |
1621
| `os.lstat(path)` | O(1) | O(1) | Stat without following symlink |
22+
| `os.access(path, mode)` | O(1) | O(1) | Check file accessibility |
1723
| `os.remove(path)` | O(1) | O(1) | Delete file |
24+
| `os.unlink(path)` | O(1) | O(1) | Delete file (alias for remove) |
1825
| `os.mkdir(path)` | O(1) | O(1) | Create directory |
1926
| `os.makedirs(path)` | O(n) | O(1) | Create directories, n = depth |
2027
| `os.rmdir(path)` | O(1) | O(1) | Remove empty directory |
28+
| `os.removedirs(path)` | O(n) | O(1) | Remove empty directories recursively |
2129
| `os.rename(src, dst)` | O(1) | O(1) | Rename/move file |
30+
| `os.replace(src, dst)` | O(1) | O(1) | Rename, overwriting dst if exists |
31+
| `os.link(src, dst)` | O(1) | O(1) | Create hard link |
32+
| `os.symlink(src, dst)` | O(1) | O(1) | Create symbolic link |
33+
| `os.readlink(path)` | O(1) | O(n) | Read symlink target |
2234
| `os.chmod(path, mode)` | O(1) | O(1) | Change permissions |
35+
| `os.chown(path, uid, gid)` | O(1) | O(1) | Change owner/group |
36+
| `os.truncate(path, length)` | O(1) | O(1) | Truncate file to length |
37+
38+
## Process and Environment
39+
40+
| Operation | Time | Space | Notes |
41+
|-----------|------|-------|-------|
42+
| `os.getcwd()` | O(1) | O(n) | Get current working directory |
43+
| `os.chdir(path)` | O(1) | O(1) | Change working directory |
44+
| `os.getenv(key)` | O(1) | O(1) | Get environment variable |
45+
| `os.putenv(key, value)` | O(1) | O(1) | Set environment variable |
46+
| `os.getpid()` | O(1) | O(1) | Get current process ID |
47+
| `os.getppid()` | O(1) | O(1) | Get parent process ID |
48+
| `os.getuid()` | O(1) | O(1) | Get current user ID |
49+
| `os.getgid()` | O(1) | O(1) | Get current group ID |
50+
| `os.uname()` | O(1) | O(1) | Get system information |
51+
| `os.cpu_count()` | O(1) | O(1) | Get number of CPUs |
2352

2453
## Path Operations
2554

docs/stdlib/pathlib.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,41 @@ The `pathlib` module provides an object-oriented approach to filesystem path han
1313
| `Path.is_file()` | O(1) | O(1) | Check if path is file |
1414
| `Path.is_dir()` | O(1) | O(1) | Check if path is directory |
1515
| `Path.is_symlink()` | O(1) | O(1) | Check if path is symlink |
16+
| `Path.is_mount()` | O(1) | O(1) | Check if path is mount point |
17+
| `Path.is_socket()` | O(1) | O(1) | Check if path is socket |
18+
| `Path.is_fifo()` | O(1) | O(1) | Check if path is FIFO |
19+
| `Path.is_block_device()` | O(1) | O(1) | Check if path is block device |
20+
| `Path.is_char_device()` | O(1) | O(1) | Check if path is char device |
1621
| `Path.stat()` | O(1) | O(1) | Get file stats |
22+
| `Path.lstat()` | O(1) | O(1) | Like stat but don't follow symlinks |
1723
| `Path.resolve()` | O(n) | O(n) | Resolve to absolute path |
24+
| `Path.absolute()` | O(1) | O(n) | Make absolute without resolving symlinks |
25+
| `Path.expanduser()` | O(1) | O(n) | Expand ~ to home directory |
1826
| `Path.iterdir()` | O(d) | O(d) | Iterate directory contents |
27+
| `Path.walk()` | O(d) | O(d) | Walk directory tree (Python 3.12+) |
1928
| `Path.glob(pattern)` | O(n) | O(1) per item | n = directory entries checked, returns iterator |
2029
| `Path.rglob(pattern)` | O(n) | O(1) per item | n = total tree entries, returns iterator |
2130
| `Path.mkdir()` | O(1) | O(1) | Create directory |
31+
| `Path.touch()` | O(1) | O(1) | Create file or update timestamp |
2232
| `Path.rename(target)` | O(1) | O(1) | Rename path |
33+
| `Path.replace(target)` | O(1) | O(1) | Rename, overwriting target if exists |
2334
| `Path.unlink()` | O(1) | O(1) | Delete file |
2435
| `Path.rmdir()` | O(1) | O(1) | Delete empty directory |
36+
| `Path.symlink_to(target)` | O(1) | O(1) | Create symlink |
37+
| `Path.hardlink_to(target)` | O(1) | O(1) | Create hard link |
38+
| `Path.readlink()` | O(1) | O(n) | Read symlink target |
39+
| `Path.chmod(mode)` | O(1) | O(1) | Change file mode |
40+
| `Path.lchmod(mode)` | O(1) | O(1) | chmod without following symlinks |
41+
| `Path.owner()` | O(1) | O(1) | Get owner name |
42+
| `Path.group()` | O(1) | O(1) | Get group name |
43+
| `Path.samefile(other)` | O(1) | O(1) | Check if same file |
44+
| `Path.open(mode)` | O(1) | O(1) | Open file (returns file object) |
2545
| `Path.read_text()` | O(n) | O(n) | Read file as text |
2646
| `Path.read_bytes()` | O(n) | O(n) | Read file as bytes |
2747
| `Path.write_text()` | O(n) | O(n) | Write text to file |
2848
| `Path.write_bytes()` | O(n) | O(n) | Write bytes to file |
49+
| `Path.as_uri()` | O(n) | O(n) | Return file:// URI |
50+
| `Path.from_uri(uri)` | O(n) | O(n) | Create Path from URI (Python 3.13+) |
2951

3052
## Path Construction
3153

0 commit comments

Comments
 (0)