Project: Julian Day Number
Write a function that computes the Julian Day Number given the month, day and year of a date of the proleptic Gregorian calendar. The Julian day is the number of days between the given date and November 24, 4714 BC in the proleptic Gregorian calendar. Assert preconditions that check for valid month, day and year values and postconition that the result is >= 0. Accept the month, day and year as command line arguments. Use negative years for BCE years such as -4713 = 4714BCE, -100 = 101BCE, -20 = 21BCE, and 0 = 1BCE all because there is no year 0 in the proleptic Gregorian calendar.
See [[Julian day]]
Output
$ rustc JulianDay.rs
error: unknown format trait `s`
--> JulianDay.rs:32:38
|
32 | println!("{}", format!("Syntax: {0:s} month day year", utils::program_name().expect("program name should not be empty!")));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error: unknown format trait `d`
--> JulianDay.rs:37:29
|
37 | println!("{}", format!("{0:d}/{1:d}/{2:d} = {3:d} Julian", month, day, year, jdn));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error: unknown format trait `d`
--> JulianDay.rs:37:35
|
37 | println!("{}", format!("{0:d}/{1:d}/{2:d} = {3:d} Julian", month, day, year, jdn));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error: unknown format trait `d`
--> JulianDay.rs:37:41
|
37 | println!("{}", format!("{0:d}/{1:d}/{2:d} = {3:d} Julian", month, day, year, jdn));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error: unknown format trait `d`
--> JulianDay.rs:37:49
|
37 | println!("{}", format!("{0:d}/{1:d}/{2:d} = {3:d} Julian", month, day, year, jdn));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error[E0425]: cannot find value `args` in this scope
--> JulianDay.rs:27:5
|
27 | if args.len() == 4 {
| ^^^^ not found in this scope
|
help: consider importing this function
|
7 + use std::env::args;
|
error[E0425]: cannot find value `Utils` in this scope
--> JulianDay.rs:28:11
|
28 | month = Utils.stoiWithDefault(args[1], 0);
| ^^^^^ not found in this scope
error[E0425]: cannot find value `args` in this scope
--> JulianDay.rs:28:33
|
28 | month = Utils.stoiWithDefault(args[1], 0);
| ^^^^ not found in this scope
|
help: consider importing this function
|
7 + use std::env::args;
|
error[E0425]: cannot find value `Utils` in this scope
--> JulianDay.rs:29:9
|
29 | day = Utils.stoiWithDefault(args[2], 0);
| ^^^^^ not found in this scope
error[E0425]: cannot find value `args` in this scope
--> JulianDay.rs:29:31
|
29 | day = Utils.stoiWithDefault(args[2], 0);
| ^^^^ not found in this scope
|
help: consider importing this function
|
7 + use std::env::args;
|
error[E0425]: cannot find value `Utils` in this scope
--> JulianDay.rs:30:10
|
30 | year = Utils.stoiWithDefault(args[3], 0);
| ^^^^^ not found in this scope
error[E0425]: cannot find value `args` in this scope
--> JulianDay.rs:30:32
|
30 | year = Utils.stoiWithDefault(args[3], 0);
| ^^^^ not found in this scope
|
help: consider importing this function
|
7 + use std::env::args;
|
error[E0425]: cannot find function `exit` in this scope
--> JulianDay.rs:33:3
|
33 | exit(1);
| ^^^^ not found in this scope
|
help: consider importing this function
|
7 + use std::process::exit;
|
error: aborting due to 13 previous errors
For more information about this error, try `rustc --explain E0425`.
$ rustc JulianDay.rs
error: unknown format trait `s`
--> JulianDay.rs:32:38
|
32 | println!("{}", format!("Syntax: {0:s} month day year", utils::program_name().expect("program name should not be empty!")));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error: unknown format trait `d`
--> JulianDay.rs:37:29
|
37 | println!("{}", format!("{0:d}/{1:d}/{2:d} = {3:d} Julian", month, day, year, jdn));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error: unknown format trait `d`
--> JulianDay.rs:37:35
|
37 | println!("{}", format!("{0:d}/{1:d}/{2:d} = {3:d} Julian", month, day, year, jdn));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error: unknown format trait `d`
--> JulianDay.rs:37:41
|
37 | println!("{}", format!("{0:d}/{1:d}/{2:d} = {3:d} Julian", month, day, year, jdn));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error: unknown format trait `d`
--> JulianDay.rs:37:49
|
37 | println!("{}", format!("{0:d}/{1:d}/{2:d} = {3:d} Julian", month, day, year, jdn));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error[E0425]: cannot find value `args` in this scope
--> JulianDay.rs:27:5
|
27 | if args.len() == 4 {
| ^^^^ not found in this scope
|
help: consider importing this function
|
7 + use std::env::args;
|
error[E0425]: cannot find value `Utils` in this scope
--> JulianDay.rs:28:11
|
28 | month = Utils.stoiWithDefault(args[1], 0);
| ^^^^^ not found in this scope
error[E0425]: cannot find value `args` in this scope
--> JulianDay.rs:28:33
|
28 | month = Utils.stoiWithDefault(args[1], 0);
| ^^^^ not found in this scope
|
help: consider importing this function
|
7 + use std::env::args;
|
error[E0425]: cannot find value `Utils` in this scope
--> JulianDay.rs:29:9
|
29 | day = Utils.stoiWithDefault(args[2], 0);
| ^^^^^ not found in this scope
error[E0425]: cannot find value `args` in this scope
--> JulianDay.rs:29:31
|
29 | day = Utils.stoiWithDefault(args[2], 0);
| ^^^^ not found in this scope
|
help: consider importing this function
|
7 + use std::env::args;
|
error[E0425]: cannot find value `Utils` in this scope
--> JulianDay.rs:30:10
|
30 | year = Utils.stoiWithDefault(args[3], 0);
| ^^^^^ not found in this scope
error[E0425]: cannot find value `args` in this scope
--> JulianDay.rs:30:32
|
30 | year = Utils.stoiWithDefault(args[3], 0);
| ^^^^ not found in this scope
|
help: consider importing this function
|
7 + use std::env::args;
|
error[E0425]: cannot find function `exit` in this scope
--> JulianDay.rs:33:3
|
33 | exit(1);
| ^^^^ not found in this scope
|
help: consider importing this function
|
7 + use std::process::exit;
|
error: aborting due to 13 previous errors
For more information about this error, try `rustc --explain E0425`.