Skip to content

Commit fe4fc3e

Browse files
authored
Merge branch 'cron' into cron-fix
2 parents 4699462 + 395c9c4 commit fe4fc3e

File tree

314 files changed

+29114
-519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

314 files changed

+29114
-519
lines changed

Cargo.lock

+483-239
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ members = [
2121
"process",
2222
"sccs",
2323
"screen",
24+
"sh",
2425
"sys",
2526
"text",
2627
"tree",
@@ -34,7 +35,7 @@ members = [
3435
repository = "https://github.com/rustcoreutils/posixutils-rs"
3536
license = "MIT"
3637
edition = "2021"
37-
rust-version = "1.80.0"
38+
rust-version = "1.84.0"
3839

3940
[workspace.dependencies]
4041
clap = { version = "4", default-features = false, features = ["std", "derive", "help", "usage", "error-context", "cargo"] }
@@ -45,6 +46,7 @@ regex = "1.10"
4546
gettext-rs = { path = "./gettext-rs" }
4647
errno = "0.3"
4748
tempfile = "3.14"
49+
chrono-tz = "0.10"
4850

4951
[workspace.lints]
5052

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ Because it is a FAQ, the major differences between this project and uutils are:
8484
- [x] join
8585
- [x] link
8686
- [x] ls
87-
- [x] make
8887
- [x] m4
88+
- [x] make
8989
- [x] mkdir
90+
- [x] more
9091
- [x] mv
9192
- [x] nl
9293
- [x] nm (Development)
@@ -97,6 +98,8 @@ Because it is a FAQ, the major differences between this project and uutils are:
9798
- [x] realpath
9899
- [x] rm
99100
- [x] rmdir
101+
- [x] sed
102+
- [x] sh
100103
- [x] sort
101104
- [x] split
102105
- [x] strings
@@ -118,6 +121,7 @@ Because it is a FAQ, the major differences between this project and uutils are:
118121

119122
## Stage 2 - Feature-complete and POSIX compliant
120123

124+
- [x] batch (cron cat.)
121125
- [x] cat
122126
- [x] chgrp
123127
- [x] chmod
@@ -170,7 +174,6 @@ Because it is a FAQ, the major differences between this project and uutils are:
170174

171175
### Cron category
172176
- [ ] at (cron cat.)
173-
- [ ] batch (cron cat.)
174177
- [ ] crontab (cron cat.)
175178

176179
### Development category
@@ -194,11 +197,11 @@ Because it is a FAQ, the major differences between this project and uutils are:
194197

195198
### i18n category
196199
- [ ] gettext (i18n)
197-
- [ ] locale (i18n) -- status: in progress
200+
- [ ] locale (i18n)
198201
- [ ] localedef (i18n)
199202
- [ ] msgfmt (i18n)
200203
- [ ] ngettext (i18n)
201-
- [ ] xgettext (i18n) -- status: in progress
204+
- [ ] xgettext (i18n)
202205

203206
### UUCP category
204207
- [ ] uucp (UUCP)
@@ -213,12 +216,9 @@ Because it is a FAQ, the major differences between this project and uutils are:
213216
### Misc. category
214217
- [ ] lp
215218
- [ ] mailx
216-
- [ ] man (status: in progress)
217-
- [ ] more
218-
- [ ] patch (status: in progress)
219+
- [ ] man
220+
- [ ] patch
219221
- [ ] pax
220-
- [ ] sed
221-
- [ ] sh (status: in progress)
222222

223223
## Installation
224224

awk/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ libc.workspace = true
1313
pest = "2.7"
1414
pest_derive = "2.7"
1515
lexical = { version = "6.1", features = ["format"] }
16-
rand = {version = "0.8", default-features = false, features = ["small_rng"] }
16+
rand = { version = "0.8", default-features = false, features = ["small_rng"] }
1717

1818
[dev-dependencies]
1919
plib = { path = "../plib" }
@@ -23,4 +23,4 @@ workspace = true
2323

2424
[[bin]]
2525
name = "awk"
26-
path = "src/main.rs"
26+
path = "main.rs"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

datetime/cal.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -52,37 +52,37 @@ fn print_month(month: u32, year: u32) {
5252
_ => unreachable!(),
5353
};
5454

55-
println!("{} {}", month_name, year);
55+
println!(" {} {}", month_name, year);
5656
println!("{}", gettext("Su Mo Tu We Th Fr Sa"));
5757

58-
let mut day = 1;
59-
let mut weekday = 1;
60-
let mut days_in_month = 31;
61-
if month == 4 || month == 6 || month == 9 || month == 11 {
62-
days_in_month = 30;
63-
} else if month == 2 {
64-
if year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) {
65-
days_in_month = 29;
66-
} else {
67-
days_in_month = 28;
58+
let first_day = chrono::NaiveDate::from_ymd_opt(year as i32, month, 1).unwrap();
59+
let start_weekday = first_day.weekday().num_days_from_sunday(); // 0 (Sun) to 6 (Sat)
60+
61+
let days_in_month = match month {
62+
4 | 6 | 9 | 11 => 30,
63+
2 => {
64+
if year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) {
65+
29
66+
} else {
67+
28
68+
}
6869
}
70+
_ => 31,
71+
};
72+
73+
// Print initial padding
74+
for _ in 0..start_weekday {
75+
print!(" ");
6976
}
7077

71-
while day <= days_in_month {
72-
print!("{:2}", day);
73-
day += 1;
74-
weekday += 1;
75-
if weekday > 7 {
78+
for day in 1..=days_in_month {
79+
print!("{:2} ", day);
80+
if (start_weekday + day) % 7 == 0 {
7681
println!();
77-
weekday = 1;
78-
} else {
79-
print!(" ");
8082
}
8183
}
8284

83-
if weekday != 1 {
84-
println!();
85-
}
85+
println!();
8686
}
8787

8888
fn print_year(year: u32) {

0 commit comments

Comments
 (0)