Skip to content

Commit 3c96932

Browse files
committed
Calculate current month and year
1 parent 10a2dc6 commit 3c96932

File tree

2 files changed

+82
-9
lines changed

2 files changed

+82
-9
lines changed

src/bootstrap/Cargo.lock

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

src/bootstrap/dist.rs

+61-9
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,23 @@ pub fn rustc(build: &Build, stage: u32, host: &str) {
212212
// Man pages
213213
t!(fs::create_dir_all(image.join("share/man/man1")));
214214
//cp_r(&build.src.join("man"), &image.join("share/man/man1"));
215+
let now_string = calc_now_string();
216+
println!("Searchable 98hnandsf9ifnesd");
215217
for man_page_source in t!(build.src.join("man").read_dir()).map(|e| t!(e)) {
216-
let os_filename = entry.file_name();
217-
let filename = t!(os_filename.into_string());
218+
let os_filename = man_page_source.file_name();
218219

219-
// Match all source files
220-
if filename.ends_with(".1.in") {
221-
// TODO generate header somehow
222-
}
223-
// Match all generated files
224-
if filename.ends_with(".1") {
225-
// TODO copy them
220+
if let Some(filename) = os_filename.to_str() {
221+
222+
// Match all source files
223+
if filename.ends_with(".1.in") {
224+
let header = format!(r##".TH RUSTC "1" "{now_string}" "rustc 1.12.0" "User Commands""##, now_string=now_string);
225+
226+
println!("build: {:?}\nheader: {:?}", build.release, header);
227+
}
228+
// Match all generated files
229+
if filename.ends_with(".1") {
230+
// TODO copy them
231+
}
226232
}
227233
}
228234

@@ -238,6 +244,52 @@ pub fn rustc(build: &Build, stage: u32, host: &str) {
238244
cp("LICENSE-MIT");
239245
cp("README.md");
240246
}
247+
248+
fn calc_now_string() -> String {
249+
use std::time::*;
250+
251+
let now = SystemTime::now();
252+
let now = now.duration_since(UNIX_EPOCH).unwrap();
253+
let secs = now.as_secs();
254+
255+
let years = secs / (60 * 60 * 24 * 365);
256+
257+
let year_secs = 60 * 60 * 24 * 365; // n seconds per year
258+
let years_secs = years * year_secs; // seconds all past years used up
259+
260+
let this_years_secs = secs - years_secs;
261+
262+
let january : u64 = 60*60*24* 31;
263+
let february : u64 = january + (60f64*60f64*24f64* 28.25) as u64;
264+
let march : u64 = february + 60*60*24* 31;
265+
let april : u64 = march + 60*60*24* 30;
266+
let may : u64 = april + 60*60*24* 31;
267+
let june : u64 = may + 60*60*24* 30;
268+
let july : u64 = june + 60*60*24* 31;
269+
let august : u64 = july + 60*60*24* 31;
270+
let september : u64 = august + 60*60*24* 30;
271+
let october : u64 = september + 60*60*24* 31;
272+
let november : u64 = october + 60*60*24* 30;
273+
274+
let month =
275+
if this_years_secs < january { "January" } else
276+
if this_years_secs < february { "February" } else
277+
if this_years_secs < march { "March" } else
278+
if this_years_secs < april { "April" } else
279+
if this_years_secs < may { "May" } else
280+
if this_years_secs < june { "June" } else
281+
if this_years_secs < july { "July" } else
282+
if this_years_secs < august { "August" } else
283+
if this_years_secs < september { "September" } else
284+
if this_years_secs < october { "October" } else
285+
if this_years_secs < november { "November" } else
286+
{ "December" }
287+
;
288+
289+
let year = years + 1970;
290+
291+
format!("{} {}", month, year)
292+
}
241293
}
242294

243295
/// Copies debugger scripts for `host` into the `sysroot` specified.

0 commit comments

Comments
 (0)