GithubHelp home page GithubHelp logo

time-rs / time Goto Github PK

View Code? Open in Web Editor NEW
1.0K 19.0 252.0 3.35 MB

The most used Rust library for date and time handling.

Home Page: https://time-rs.github.io

License: Apache License 2.0

Rust 100.00%
rust date time no-std

time's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

time's Issues

panic Tm::asctime on linux x86_64 systems

Panic when using Tm::asctime at Linux x86_64:

(simplified to reproduce the problem)

extern crate time;
use time::{Timespec, at};

fn main() {
    println!("{}", at(Timespec::new(-0x800000000000000, 0)).asctime());
}

Results in a unreachable panic:

thread '<main>' panicked at 'internal error: entered unreachable code', /home/willem/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.22/src/display.rs:134

At Linux 32-bit system, no panic happens.

Problem is caused by a invalid Tm struct created by 'at':

Tm { tm_sec: 24, tm_min: 21, tm_hour: 17, tm_mday: 32693, tm_mon: 37, tm_year: -1087444786, tm_wday: 0, tm_yday: 32693, tm_isdst: 0, tm_utcoff: 1172, tm_nsec: 0 }

This actually not caused by time crate itself, but is caused by GNU libc implementation of 'localtime_r'.

strptime does not populate all time::Tm fields

This sample code does not what's expected:

extern crate time;
fn main() {

  let t = time::at(time::Timespec::new(236928791,113000000));
  let format = "%Y-%m-%d %T.%f";

  let witness = "1977-07-05 07:33:11.113000000";
  assert_eq!(time::strftime(format, &t).ok().unwrap(), witness);

  assert_eq!(time::strptime(witness.as_ref(), format).unwrap(), t);

}

I wonder if I'm doing something wrong or the library is behaving wrong... ?

PartialOrd for Tm

Is there a reason for PartialOrd (or even Ord?) not being implemented for Tm? It would seem to me like a fairly trivial thing to have and would not require always going between Tm and Timespec.

I would think that something like this should do the trick:

impl PartialOrd for Tm {
    fn partial_cmp(&self, other: &Tm) -> Option<Ordering> {
        self.to_utc().to_timespec().partial_cmp(&other.to_utc().to_timespec())
    }
}

local time format error: rfc822

Issue by zengsai
Friday Aug 29, 2014 at 08:08 GMT

For earlier discussion, see rust-lang/rust#16841

This issue was labelled with: in the Rust repository


Source Code:

extern crate time;

fn main() {
    let utc = time::now_utc();
    let local = time::now();

    println!("utc:   {}", utc.rfc822());
    println!("local: {}", local.rfc822());
}

Console Output:

utc:   Fri, 29 Aug 2014 08:05:12 GMT
local: Fri, 29 Aug 2014 16:05:12 strftime: can't understand this format Z

According to the document of this API, the correct output should be:

utc:   Fri, 29 Aug 2014 08:05:12 GMT
local: Fri, 29 Aug 2014 16:05:12 PST

can't use time on windows

I'm using rust on windows
rustc 0.13.0-nightly (636663172 2014-12-28 16:21:58 +0000)
cargo 0.0.1-pre-nightly (fd5d7a9 2014-12-25 04:28:40 +0000)

I've been using the builtin time crate in my project, but rust complains every time I use anything from it (warning: use of deprecated item: use the http://github.com/rust-lang/time crate instead). So to be a good rust user, I tried adding rust-lang/time to my project with:

[dependencies]
time = "*"

When I go to compile my project, I get the following errors:

MYPROJECT>cargo test -- --nocapture
   Compiling gcc v0.1.2
   Compiling time v0.1.5
Failed to run custom build command for `time v0.1.5`
Process didn't exit successfully: `MYPROJECT\target\build\time-82dafc95a42caa7e\build-script-build.exe` (status=101)
--- stdout
TARGET = Some(x86_64-pc-windows-gnu)
OPT_LEVEL = Some(0)
TARGET = Some(x86_64-pc-windows-gnu)
HOST = Some(x86_64-pc-windows-gnu)
CC_x86_64-pc-windows-gnu = None
CC_x86_64_pc_windows_gnu = None
HOST_CC = None
CC = None
TARGET = Some(x86_64-pc-windows-gnu)
HOST = Some(x86_64-pc-windows-gnu)
CFLAGS_x86_64-pc-windows-gnu = None
CFLAGS_x86_64_pc_windows_gnu = None
HOST_CFLAGS = None
CFLAGS = None
CARGO_MANIFEST_DIR = Some(MYHOME\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.5)
OUT_DIR = Some(MYPROJECT\target\build\time-82dafc95a42caa7e\out)
running: gcc '-O0' '-c' '-ffunction-sections' '-fdata-sections' '-m64' '-fPIC' 'MYHOME\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.5\src\time_helpers.c' '-o' 'MYPROJECT\target\build\time-82dafc95a42caa7e\out\src\time_helpers.o'

--- stderr
thread '<main>' panicked at 'failed to spawn process: file not found (OS Error 2: The system cannot find the file specified.
)', MYHOME\.cargo\registry\src\github.com-1ecc6299db9ec823\gcc-0.1.2\src\lib.rs:116

(I replaced the full directories with MYHOME and MYPROJECT).

I assume it's trying to call gcc, which I don't have on the path. I've had immense difficulty getting rust to work with cygwin or my own MinGW installations, so the only way I've managed to get things to work on Windows is to let rust use its builtin gcc (as described in https://github.com/rust-lang/rust/wiki/Using-Rust-on-Windows). This seems to be the recommended way of running rust on windows now. Is it possible for time to use that gcc as well?

Build fails on Windows

Now that the time library has been moved to this repository, it has become unusable on Windows. When I run cargo build --verbose in this repository, I get:

unused manifest key: build-dependencies.gcc.git
   Compiling time v0.0.1 (file:///<path removed>)
     Running build.rs
Failed to run custom build command for `time v0.0.1 (file:///<path removed>)`
Could not execute process `build.rs` (status=never executed)

Caused by:
  OS Error 193: %1 is geen geldige Win32-toepassing.

Translation of the OS error: “%1 is not a valid Win32 application”.

When I add time as dependency of an other project, and run cargo build --verbose, I get:

   Compiling time v0.0.1 (https://github.com/rust-lang/time.git#d6219df8)
     Running build.rs
Failed to run custom build command for `time v0.0.1 (https://github.com/rust-lang/time.git#d6219df8)`
Could not execute process `build.rs` (status=never executed)

Caused by:
  file not found (OS Error 2: Het systeem kan het opgegeven bestand niet vinden.)

Translation of the OS error: “File not found.”

When the time library was included in the standard library, a binary version was included with the installer, so users did not have to have all the tools and dependencies available to build this. Also, getting a working version of GCC on Windows is not trivial at all in my experience.

timezone support for strftime

When I use time::strftime("%Y-%m-%d %H:%M:%S %Z", &time::now()).unwrap(), I get timestamp without timezone. Here is output I get. 2014-12-18 12:32:31

How do I get timezone printed?

Here is equivalent python code

import datetime
import pytz
d = datetime.datetime.now(pytz.timezone("America/New_York"))
d.strftime("%Y-%m-%d %H:%M:%S %Z")

'2014-12-18 12:41:19 EST'

Parsing Fractional Seconds

As far as I can tell, strptime only has one option in order to parse fractional seconds: %f. Unfortunately, this is really inconvenient since it expects nine digits and thus a time format such as 2014-12-27 10:11:12.3215 currently cannot be parsed.

Could not compile libc.

$ rustc --version
rustc 1.0.0-nightly (c89de2c56 2015-03-28) (built 2015-03-28)
$cargo build --verbose
   Compiling libc v0.1.3
     Running `rustc /Users/heaven/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.1.3/rust/src/liblibc/lib.rs --crate-name libc --crate-type lib -g --cfg feature="default" --cfg feature="cargo-build" -C metadata=2a692f33a70517c8 -C extra-filename=-2a692f33a70517c8 --out-dir /Users/heaven/GitRep/time/target/debug/deps --emit=dep-info,link -L dependency=/Users/heaven/GitRep/time/target/debug/deps -L dependency=/Users/heaven/GitRep/time/target/debug/deps -Awarnings`
   Compiling time v0.1.21 (file:///Users/heaven/GitRep/time)
     Running `rustc build.rs --crate-name build_script_build --crate-type bin -C prefer-dynamic -g --out-dir /Users/heaven/GitRep/time/target/debug/build/time-bd75c04eb6b24a83 --emit=dep-info,link -L dependency=/Users/heaven/GitRep/time/target/debug -L dependency=/Users/heaven/GitRep/time/target/debug/deps --extern gcc=/Users/heaven/GitRep/time/target/debug/deps/libgcc-aa09d64454af40df.rlib`
       Fresh gcc v0.3.3
       Fresh log v0.2.5
/Users/heaven/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.1.3/rust/src/liblibc/lib.rs:79:46: 79:51 error: expected ident, found `"std"`
/Users/heaven/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.1.3/rust/src/liblibc/lib.rs:79 #[cfg(feature = "cargo-build")] extern crate "std" as core;
                                                                                                                                                 ^~~~~
Build failed, waiting for other jobs to finish...
Could not compile `libc`.

Caused by:
  Process didn't exit successfully: `rustc /Users/heaven/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.1.3/rust/src/liblibc/lib.rs --crate-name libc --crate-type lib -g --cfg feature="default" --cfg feature="cargo-build" -C metadata=2a692f33a70517c8 -C extra-filename=-2a692f33a70517c8 --out-dir /Users/heaven/GitRep/time/target/debug/deps --emit=dep-info,link -L dependency=/Users/heaven/GitRep/time/target/debug/deps -L dependency=/Users/heaven/GitRep/time/target/debug/deps -Awarnings` (exit code: 101)

Installation failed in Win7 x64

Hello guys and girls.
Any ideas on my problem? I got this while trying to install "time" (Win7 x64, rust x64 nightly):

Zebra@ZEBRA-VAIO /c/try/try002 (master)
$ cargo run
    Updating registry `https://github.com/rust-lang/crates.io-index`
 Downloading time v0.1.9
 Downloading rustc-serialize v0.2.4
 Downloading gcc v0.1.3
 Downloading rust-crypto v0.2.10
   Compiling rustc-serialize v0.2.4
   Compiling gcc v0.1.3
   Compiling time v0.1.9
Build failed, waiting for other jobs to finish...
failed to run custom build command for `time v0.1.9`
Process didn't exit successfully: `C:\try\try002\target\build\time-7acca1f21e6e9
c62\build-script-build.exe` (status=101)
--- stdout
TARGET = Some(x86_64-pc-windows-gnu)
OPT_LEVEL = Some(0)
TARGET = Some(x86_64-pc-windows-gnu)
HOST = Some(x86_64-pc-windows-gnu)
CC_x86_64-pc-windows-gnu = None
CC_x86_64_pc_windows_gnu = None
HOST_CC = None
CC = None
TARGET = Some(x86_64-pc-windows-gnu)
HOST = Some(x86_64-pc-windows-gnu)
CFLAGS_x86_64-pc-windows-gnu = None
CFLAGS_x86_64_pc_windows_gnu = None
HOST_CFLAGS = None
CFLAGS = None
CARGO_MANIFEST_DIR = Some(C:\Users\Zebra\.cargo\registry\src\github.com-1ecc6299
db9ec823\time-0.1.9)
OUT_DIR = Some(C:\try\try002\target\build\time-7acca1f21e6e9c62\out)
running: gcc '-O0' '-c' '-ffunction-sections' '-fdata-sections' '-m64' '-fPIC' '
C:\Users\Zebra\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.9\src\ti
me_helpers.c' '-o' 'C:\try\try002\target\build\time-7acca1f21e6e9c62\out\src\tim
e_helpers.o'

--- stderr
C:\Users\Zebra\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.9\src\ti
me_helpers.c:1:0: warning: -fPIC ignored for target (all code is position indepe
ndent)
 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
 ^
C:\Users\Zebra\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.9\src\ti
me_helpers.c:28:19: fatal error: tchar.h: No such file or directory
 #include <tchar.h>
                   ^
compilation terminated.
thread '<main>' panicked at 'nonzero exit status: exit code: 1', C:\Users\Zebra\
.cargo\registry\src\github.com-1ecc6299db9ec823\gcc-0.1.3\src\lib.rs:119

properly parse timezones

I'm not sure about the policy here but right now the timezones are not parsed correctly which makes working with timestamps from different timezones impossible unless done by hand.

I'm referring to %z here and not %Z .

Any thoughts on this?

Build failed on Win7, time_helpers.o file missing

PS C:\Users\DAS\Projects\rust> git clone https://github.com/rust-lang/time.git
Cloning into 'time'...
remote: Counting objects: 69, done.
remote: Total 69 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (69/69), done.
Checking connectivity... done.
PS C:\Users\DAS\Projects\rust> cd time
PS C:\Users\DAS\Projects\rust\time> cargo build
    Updating git repository `https://github.com/alexcrichton/gcc-rs`
   Compiling gcc v0.0.2 (https://github.com/alexcrichton/gcc-rs#903e8f8a)
   Compiling time v0.0.3 (file:///C:/Users/DAS/Projects/rust/time)
Failed to run custom build command for `time v0.0.3 (file:///C:/Users/DAS/Projects/rust/time)`
Process didn't exit successfully: `C:\Users\DAS\Projects\rust\time\target\build\time-5640c8a5c7ff68e7\build-script-build.exe` (status=101)
--- stdout
running: gcc '-O0' '-c' '-ffunction-sections' '-fdata-sections' '-m64' '-fPIC' 'C:\Users\DAS\Projects\rust\time\src\time_helpers.c' '-o' 'C:\Users\DAS\Projects\rust\time\target\build\time-5640c8a5c7ff68e7\out\src\time_helpers.o'

--- stderr
task '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: file not found (OS Error 2: The system cannot find the file specified.
)', C:\bot\slave\nightly-win-64\build\src\libcore\result.rs:743

In looking for what The system cannot find the file specified. might mean, I found that the time_helpers.o file was missing. The directory exists, but the .o file is not there.

Because it's mentioned here, you should know there are multiple gcc.exes in my system, but none of them are in my PATH. The gcc it should be using then is the one at C:\Program Files (x86)\Rust\bin\rustlib\x86_64-pc-windows-gnu\bin\gcc.exe. Here's its version info:
gcc version 4.9.1 (x86_64-win32-seh-rev1, Built by MinGW-W64 project)

Standard environment info:
Windows 7, 64-bit
rustc 0.13.0-nightly (395901393 2014-11-24 00:46:30 +0000)
cargo 0.0.1-pre-nightly (65bdc57 2014-11-25 00:00:54 +0000)

Compatibility with Duration

A couple of questions/issues:

  • I see that Timespec + Duration is implemented, but is there a reason for Timespec - Duration to not be implemented?
  • Is it intended that Tm offers no compatibility with adding and subtracting Durations? Since Timespec offers (some) compatibility, It would seem fairly easy convert to a Timespec, perform the addition, and then convert back to Tm afterwards (although I guess there could be more efficient ways of achieving this).

Cargo error: "Could not execute process `build.rs`

I am getting the following error when I try to build the time package:

~/.cargo/git/checkouts/time-d59bff975f117a1a/master$ cargo build --verbose                                                                                                                             
unused manifest key: build-dependencies.gcc.git                                                                                                                                                                    
unused manifest key: package.description                                                                                                                                                                           
unused manifest key: package.homepage                                                                                                                                                                              
unused manifest key: package.license                                                                                                                                                                               
unused manifest key: package.repository                                                                                                                                                                            
   Compiling time v0.0.3 (file:///home/dso/.cargo/git/checkouts/time-d59bff975f117a1a/master)                                                                                                                      
     Running build.rs                                                                                                                                                                                              
Failed to run custom build command for `time v0.0.3 (file:///home/dso/.cargo/git/checkouts/time-d59bff975f117a1a/master)`                                                                                          
Could not execute process `build.rs` (status=never executed)

Caused by:
  no such file or directory

Rust version:

rustc -v
rustc 0.13.0-dev (96c8f2b0c 2014-11-20 16:02:03 +0000)

Cargo version:

~/.cargo/git/checkouts/time-d59bff975f117a1a/master$ cargo --version
cargo 0.0.1-pre-nightly (9788700 2014-10-15 20:14:53 +0000)

I am not sure if this is related to the version of rustc, cargo, or a build issue with the time crate.

Could not execute process `build.rs` (status=never executed)

I tried to add time as a dependency in my Cargo.toml, and receive this error:

% cargo build --verbose
   Compiling time v0.0.1 (https://github.com/rust-lang/time#f8c6b514)
     Running build.rs
Failed to run custom build command for `time v0.0.1 (https://github.com/rust-lang/time#f8c6b514)`
Could not execute process `build.rs` (status=never executed)

Caused by:
  no such file or directory

A trivial reproducer is here: https://github.com/jgallagher/building_time. I'm not sure this is an issue with time - maybe a Cargo bug?

Won't compile for me on ARM

time won't cross-compile for me to ARM. I'm using Ubuntu 14.10 and the error I get is:

failed to run custom build command for `time v0.1.17`
Process didn't exit successfully: `/home/enix/code/rust-crypto/target/build/time-3fdd29c1b6f5cc42/build-script-build` (status=101)
--- stdout
TARGET = Some("arm-linux-androideabi")
OPT_LEVEL = Some("0")
TARGET = Some("arm-linux-androideabi")
HOST = Some("x86_64-unknown-linux-gnu")
CC_arm-linux-androideabi = None
CC_arm_linux_androideabi = None
TARGET_CC = None
CC = None
TARGET = Some("arm-linux-androideabi")
HOST = Some("x86_64-unknown-linux-gnu")
CFLAGS_arm-linux-androideabi = None
CFLAGS_arm_linux_androideabi = None
TARGET_CFLAGS = None
CFLAGS = None
CARGO_MANIFEST_DIR = Some("/home/enix/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.17")
OUT_DIR = Some("/home/enix/code/rust-crypto/target/arm-linux-androideabi/build/time-3fdd29c1b6f5cc42/out")
running: "arm-linux-androideabi-gcc" '"-O0"' '"-c"' '"-ffunction-sections"' '"-fdata-sections"' '"-fPIC"' '"/home/enix/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.17/src/time_helpers.c"' '"-o"' '"/home/enix/code/rust-crypto/target/arm-linux-androideabi/build/time-3fdd29c1b6f5cc42/out/src/time_helpers.o"'

--- stderr
/home/enix/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.17/src/time_helpers.c:42:15: error: static declaration of 'timegm' follows non-static declaration
In file included from /home/enix/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.17/src/time_helpers.c:12:0:
/usr/lib/gcc/arm-linux-androideabi/4.7.4/../../../../arm-linux-androideabi/include/time.h:114:15: note: previous declaration of 'timegm' was here
thread '<main>' panicked at 'nonzero exit status: exit code: 1', /home/enix/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.1.7/src/lib.rs:125

time_helpers.c redefines the timegc structure which is what is causing the error. There is a comment saying that it isn't defined on Android - which it might not be - but it appears to be defined in the header files used by the android cross compiler in ubuntu. If I comment out that structure (starting around line 42) everything seems to work fine.

strptime and time zones

strptime is not handling time zones correctly. For example, if you use the format string "%FT%T%z" with ISO 8601 strings like
1999-05-31T13:20:00-04:00
and
1999-05-31T13:20:00-05:00
you get identical results back.

The code on line 510 seems seems to match the time zone offset but it only does something when the offset if zero.

Imported from rust-lang/rust#2637

Build failure on Windows

Installed latest nightly yesterday, cargo gives deprecated warning about time crate. But it's impossible to build:

C:\Users\Michael\Documents\GitHub\time [master]> cargo build
unused manifest key: build-dependencies.gcc.git
   Compiling time v0.0.1 (file:///C:/Users/Michael/Documents/GitHub/time)
Failed to run custom build command for `time v0.0.1 (file:///C:/Users/Michael/Do
cuments/GitHub/time)`
Could not execute process `build.rs` (status=never executed)

To learn more, run the command again with --verbose.
C:\Users\Michael\Documents\GitHub\time [master]> cargo build --verbose
unused manifest key: build-dependencies.gcc.git
   Compiling time v0.0.1 (file:///C:/Users/Michael/Documents/GitHub/time)
     Running build.rs
Failed to run custom build command for `time v0.0.1 (file:///C:/Users/Michael/Do
cuments/GitHub/time)`
Could not execute process `build.rs` (status=never executed)

Caused by:
  OS Error 193: %1 не является приложением Win32.

Cannot compile on windows

I'm using the latest version of the rust compiler on Windows to compile rust-crypto, which depends on time. I am getting the following error when I try and build my project.

$ rustc --version
rustc 1.0.0-nightly (74b874071 2015-02-08 00:24:03 +0000)

$ cargo build --verbose
       Fresh libc v0.1.2
       Fresh log v0.2.2
       Fresh gcc v0.1.7
       Fresh rustc-serialize v0.2.12
       Fresh rand v0.1.2
       Fresh getopts v0.2.3
       Fresh time v0.1.16
       Fresh rust-crypto v0.2.15
   Compiling deduper v0.0.1 (file:///F:/Coding/rust-deduper)
     Running `rustc main.rs --crate-name deduper --crate-type bin -g --out-dir F:\Coding\rust-deduper\target --emit=dep-info,link -L dependency=F:\Coding\rust-deduper\target -L dependency=F:\Coding\rust-deduper\target\deps --extern crypto=F:\Coding\rust-deduper\target\deps\libcrypto-24da0b4009abc223.rlib --extern getopts=F:\Coding\rust-deduper\target\deps\libgetopts-a6c123c21f99fb4b.rlib -L native=F:\Coding\rust-deduper\target\build\time-69a93874bd2e0ce7\out`
main.rs:12:5: 12:21 warning: unused import, #[warn(unused_imports)] on by default
main.rs:12 use getopts::Options;
               ^~~~~~~~~~~~~~~~
main.rs:15:16: 15:24 warning: use of deprecated item: use env::args instead, #[warn(deprecated)] on by default
main.rs:15     let args = os::args();
                          ^~~~~~~~
main.rs:42:9: 42:71 warning: unused result which must be used, #[warn(unused_must_use)] on by default
main.rs:42         out_file.write_str(format!("{}\n", dup.display()).as_slice());
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: linking with `gcc` failed: exit code: 1
note: "gcc" '"-Wl,--enable-long-section-names"' '"-fno-use-linker-plugin"' '"-Wl,--nxcompat"' '"-static-libgcc"' '"-m64"' '"-L"' '"C:\\Rust\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib"' '"-o"' '"F:\\Coding\\rust-deduper\\target\\deduper.exe"' '"F:\\Coding\\rust-deduper\\target\\deduper.o"' '"-Wl,--gc-sections"' '"F:\\Coding\\rust-deduper\\target\\deps\\libcrypto-24da0b4009abc223.rlib"' '"F:\\Coding\\rust-deduper\\target\\deps\\libtime-69a93874bd2e0ce7.rlib"' '"F:\\Coding\\rust-deduper\\target\\deps\\librustc-serialize-db8cde5690079042.rlib"' '"F:\\Coding\\rust-deduper\\target\\deps\\librand-786334d103466ef3.rlib"' '"F:\\Coding\\rust-deduper\\target\\deps\\liblibc-8d21de95f4de7169.rlib"' '"F:\\Coding\\rust-deduper\\target\\deps\\libgetopts-a6c123c21f99fb4b.rlib"' '"C:\\Rust\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-4e7c5e5c.rlib"' '"C:\\Rust\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcollections-4e7c5e5c.rlib"' '"C:\\Rust\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunicode-4e7c5e5c.rlib"' '"C:\\Rust\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\librand-4e7c5e5c.rlib"' '"C:\\Rust\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-4e7c5e5c.rlib"' '"C:\\Rust\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-4e7c5e5c.rlib"' '"C:\\Rust\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-4e7c5e5c.rlib"' '"-L"' '"F:\\Coding\\rust-deduper\\target"' '"-L"' '"F:\\Coding\\rust-deduper\\target\\deps"' '"-L"' '"F:\\Coding\\rust-deduper\\target\\build\\time-69a93874bd2e0ce7\\out"' '"-L"' '"C:\\Rust\\bin\\rustlib\\x86_64-pc-windows-gnu\\lib"' '"-L"' '"F:\\Coding\\rust-deduper\\src\\.rust\\bin\\x86_64-pc-windows-gnu"' '"-L"' '"F:\\Coding\\rust-deduper\\src\\bin\\x86_64-pc-windows-gnu"' '"-Wl,--whole-archive"' '"-Wl,-Bstatic"' '"-Wl,--no-whole-archive"' '"-Wl,-Bdynamic"' '"-lws2_32"' '"-luserenv"' '"-lcompiler-rt"'
note: F:\Coding\rust-deduper\target\deps\libtime-69a93874bd2e0ce7.rlib(time-69a93874bd2e0ce7.o): In function `time::tzset':
C:\Users\Nate\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.16\src/lib.rs:599: undefined reference to `rust_time_tzset'
F:\Coding\rust-deduper\target\deps\libtime-69a93874bd2e0ce7.rlib(time-69a93874bd2e0ce7.o): In function `time::at_utc':
C:\Users\Nate\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.16\src/lib.rs:703: undefined reference to `rust_time_gmtime'
F:\Coding\rust-deduper\target\deps\libtime-69a93874bd2e0ce7.rlib(time-69a93874bd2e0ce7.o): In function `time::Tm::to_timespec':
C:\Users\Nate\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.16\src/lib.rs:733: undefined reference to `rust_time_timegm'
C:\Users\Nate\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.16\src/lib.rs:734: undefined reference to `rust_time_mktime'
F:\Coding\rust-deduper\target\deps\libtime-69a93874bd2e0ce7.rlib(time-69a93874bd2e0ce7.o): In function `time::at':
C:\Users\Nate\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.16\src/lib.rs:718: undefined reference to `rust_time_localtime'

error: aborting due to previous error
Could not compile `deduper`.

Caused by:
  Process didn't exit successfully: `rustc main.rs --crate-name deduper --crate-type bin -g --out-dir F:\Coding\rust-deduper\target --emit=dep-info,link -L dependency=F:\Coding\rust-deduper\target -L dependency=F:\Coding\rust-deduper\target\deps --extern crypto=F:\Coding\rust-deduper\target\deps\libcrypto-24da0b4009abc223.rlib --extern getopts=F:\Coding\rust-deduper\target\deps\libgetopts-a6c123c21f99fb4b.rlib -L native=F:\Coding\rust-deduper\target\build\time-69a93874bd2e0ce7\out` (status=101)

Is there a dependency that I'm missing?

Question about tm_yday

I have a question. I tested following code using rust-lang/time ver 0.1.26.

let t = Timespec { sec: 1451606399, nsec: 0 }; // timestamp of 2015-12-31 23:59:59
println!("{:?}", at_utc(t));

And I got output

Tm { tm_sec: 59, tm_min: 59, tm_hour: 23, tm_mday: 31, tm_mon: 11, tm_year: 115, tm_wday: 4, tm_yday: 364, tm_isdst: 0, tm_utcoff: 0, tm_nsec: 0 }

I expected tm_yday to be 365 because tm_yday is up to 365 in document.

Is tm_yday up to 364 in fact?

Serialization support

Hi,

Is there any plan to have full rustc-serialize support for the whole lib? Using time::Timespec forced me to use custom Json mapping instead of simply annotate my struct with RustcEncoable.

Thanks

Build failing on OSX

rustc 0.13.0-nightly (5484d6f6d 2014-12-02 00:22:00 +0000)

$gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
Failed to run custom build command for `time v0.1.0 (file:///Users/sven/rust/time)`
Process didn't exit successfully: `/Users/sven/rust/time/target/build/time-0835b624bcc96b1e/build-script-build` (status=101)
--- stderr
task '<main>' panicked at 'Environment variable 'HOST' is unset', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libcore/option.rs:325

libtime::Tm::to_utc() is slow even if already utc

Issue by seanmonstar
Friday Nov 07, 2014 at 01:29 GMT

For earlier discussion, see rust-lang/rust#18725

This issue was labelled with: in the Rust repository


Tm.to_utc() calls out to the runtime fn rust_timegm twice, once to convert to a Timespec, and a second time to convert the timespec to a new Tm with offset of 0. If a Tm is already UTC, this should skip both those calls.

can't build on windows

Using the latest rust nightly.

C:\Users\blair\time>cargo build --verbose
unused manifest key: build-dependencies.gcc.git
Compiling time v0.1.0 (file:///C:/Users/blair/time)
Running build.rs
Failed to run custom build command for time v0.1.0 (file:///C:/Users/blair/time)
Could not execute process build.rs (status=never executed)

Caused by:
OS Error 193: %1 is not a valid Win32 application.

libtime locale values

Issue by saosebastiao
Thursday Sep 18, 2014 at 17:32 GMT

For earlier discussion, see rust-lang/rust#17374

This issue was labelled with: in the Rust repository


libtime currently uses what appears to be en_US.UTF8 locale definitions hardcoded into the strftime/strptime functions.

https://github.com/rust-lang/rust/blob/master/src/libtime/lib.rs#L512-L548

These values should be derived from system-level locale definitions, such that they can be used in different locales correctly. However, I'm not sure how this would work for different operating systems/architectures. Is there a cross-platform standard practice that should guide the design of these parsing/formatting functions?

Remove C dependencies

I recently had to compile a Rust project with time as a dependency and I went through a lot of trouble having to get mingw64 on my 64 bit machine and messing around with paths to make sure that's the version that's used and not the 32 bit version. (I have 64 bit Rust and 32 bit C mingw)

Is it possible to remove the C dependencies so this project uses only Rust? That would make compiling projects with time as a dependency much easier on Windows.

Error in Build script-can't compile any package depending on time

Here's the message I'm getting:

Only `-l` and `-L` flags are allowed in build script of `time v0.1.4 (https://github.com/rust-
lang/time#67fb5a7f)`: `-L /Volumes/Mac Data/gabe/Workspaces/piston-
tutorials/r_tetris/target/build/time-040b8fe6da930644/out -l time_helpers:static`

This happens in literally every example I've tried to compile that depends on (directly or indirectly) the Rust time package. In this case, I was trying to compile the r_tetris project, which is a simple example Tetris game showing off some of the features of Piston.

This error comes up during the cargo build, and as far as I can tell there's no way to stop the error. Is this a glitch with this package or a problem with my Cargo config?

rustc version:
rustc 0.13.0-nightly (96a3c7c6a 2014-12-23 22:21:10 +0000)

Cargo version:
cargo 0.0.1-pre-nightly (e11c317 2014-12-21 20:43:45 +0000)

std::num::SignedInt doesn't exist

Hi.

I was installing time while playing with iron for web development and i found this error:

home/vampolo/.cargo/git/checkouts/time-d59bff975f117a1a/master/src/lib.rs:23:5: 23:24 error: unresolved import `std::num::SignedInt`. There is no `SignedInt` in `std::num`
/home/vampolo/.cargo/git/checkouts/time-d59bff975f117a1a/master/src/lib.rs:23 use std::num::SignedInt;
                                                                                  ^~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

Looks like that in stable Rust that has been renamed to std::num::Int.

Best

strptime() not handling optionality of leading zeroes

For many format specifiers, leading zeroes are supposed to be optional: http://pubs.opengroup.org/onlinepubs/7908799/xsh/strptime.html

I have only tested %m.

[package]
name = "test"
version = "0.0.0"
authors = [ "[email protected]" ]

[[bin]]
name = "test"
path = "main.rs"

[dependencies]
time = "*"
extern crate time;

use time::strptime;

fn main() {
    // %m is the month number [1,12]; leading zeros are permitted but not required.
    let format = "%d/%m/%Y".into_string();
    let dates = [ "24/05/2016", "24/5/2016" ];

    for date in dates.iter() {
        match strptime(*date, format.as_slice() ) {
            Ok(d) => println!("{} is valid {}, result shows as {}", date, format, d),
            Err(e) => println!("{} is invalid {} -- {}", date, format, e),
        }
    }
}
24/05/2016 is valid %d/%m/%Y, result shows as Tm { tm_sec: 0, tm_min: 0, tm_hour: 0, tm_mday: 24, tm_mon: 4, tm_year: 116, tm_wday: 0, tm_yday: 0, tm_isdst: 0, tm_utcoff: 0, tm_nsec: 0 }
24/5/2016 is invalid %d/%m/%Y -- Invalid month.

strptime add support to convert epoch time string

Hi,

i am trying to convert an epoch time in seconds to a time::Tm.
It seems that "%s" format is not recognized, I get an InvalidFormatSpecifier('s') in my example below.

extern crate time;
use time::strptime;

fn main() {
    let format = "%s";
    let date = "1236905626";

        match strptime(date, format ) {
            Ok(d) => println!("{} is valid {}, result shows as {:?}", date,  format, d),
            Err(e) => println!("{:?}", e),
        }
}

rustc --version:

rustc 1.0.0-nightly (3d0d9bb6f 2015-01-12 22:56:20 +0000)

my Cargo.toml

[package]
name = "test"
version = "0.0.0"
authors = [ "[email protected]" ]

[[bin]]
name = "test"
path = "main.rs"

[dependencies]
time = "*"

0.1.10 failing to build after unboxed closure rustc changes

I'm getting the following build errors on rustc nightly version ea6f65c5f 2015-01-06 19:47:08 +0000:

time-0.1.10/src/lib.rs:229:18: 231:15 error: type `std::sync::once::Once` does not implement any method in scope named `doit`
time-0.1.10/src/lib.rs:229             ONCE.doit(|| {
time-0.1.10/src/lib.rs:230                 imp::mach_timebase_info(&mut TIMEBASE);
time-0.1.10/src/lib.rs:231             });
time-0.1.10/src/lib.rs:229:23: 231:14 error: can't infer the "kind" of the closure, explicitly annotate it. e.g. `|&:| {}`
time-0.1.10/src/lib.rs:229             ONCE.doit(|| {
time-0.1.10/src/lib.rs:230                 imp::mach_timebase_info(&mut TIMEBASE);
time-0.1.10/src/lib.rs:231             });

Build fails with undeclared type or module `libc`

The beginning of the error, after cargo build:

   Compiling time v0.1.13
C:\Users\alex\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.13\src\lib.rs:96:27: 96:46 error: failed to resolve. Use of undeclared type or module `libc`
C:\Users\alex\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.13\src\lib.rs:96     pub fn frequency() -> libc::LARGE_INTEGER {

                                  ^~~~~~~~~~~~~~~~~~~
C:\Users\alex\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.13\src\lib.rs:96:27: 96:46 error: use of undeclared type name `libc::LARGE_INTEGER`
C:\Users\alex\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.13\src\lib.rs:96     pub fn frequency() -> libc::LARGE_INTEGER {

                                  ^~~~~~~~~~~~~~~~~~~
C:\Users\alex\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.13\src\lib.rs:97:31: 97:50 error: failed to resolve. Use of undeclared type or module `libc`
C:\Users\alex\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.13\src\lib.rs:97         static mut FREQUENCY: libc::LARGE_INTEGER = 0;

                                      ^~~~~~~~~~~~~~~~~~~

Built against the latest nightly:

$ rustc -V
rustc 1.0.0-nightly (4874ca36f 2015-01-23 00:18:57 +0000)

Windows build error: 64-bit mode not compiled in

I get the following error when trying to build time on Windows 7, 64bit system...

failed to run custom build command for `time v0.1.12`
Process didn't exit successfully: `C:\Users\alchemist\Documents\Rusty\face-blaster\target\build\time-7c7fc3eb0c12ad75\bu
ild-script-build.exe` (status=101)
--- stdout
TARGET = Some("x86_64-pc-windows-gnu")
OPT_LEVEL = Some("0")
TARGET = Some("x86_64-pc-windows-gnu")
HOST = Some("x86_64-pc-windows-gnu")
CC_x86_64-pc-windows-gnu = None
CC_x86_64_pc_windows_gnu = None
HOST_CC = None
CC = None
TARGET = Some("x86_64-pc-windows-gnu")
HOST = Some("x86_64-pc-windows-gnu")
CFLAGS_x86_64-pc-windows-gnu = None
CFLAGS_x86_64_pc_windows_gnu = None
HOST_CFLAGS = None
CFLAGS = None
CARGO_MANIFEST_DIR = Some("C:\\Users\\alchemist\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\time-0.1.12")
OUT_DIR = Some("C:\\Users\\alchemist\\Documents\\Rusty\\face-blaster\\target\\build\\time-7c7fc3eb0c12ad75\\out")
running: gcc '-O0' '-c' '-ffunction-sections' '-fdata-sections' '-mwin32' '-m64' '-fPIC' 'C:\Users\alchemist\.cargo\regi
stry\src\github.com-1ecc6299db9ec823\time-0.1.12\src\time_helpers.c' '-o' 'C:\Users\alchemist\Documents\Rusty\face-blast
er\target\build\time-7c7fc3eb0c12ad75\out\src\time_helpers.o'

--- stderr
C:\Users\alchemist\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.12\src\time_helpers.c:1:0: warning: -fPIC ig
nored for target (all code is position independent) [enabled by default]
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
^
C:\Users\alchemist\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.12\src\time_helpers.c:1:0: sorry, unimplemen
ted: 64-bit mode not compiled in
thread '<main>' panicked at 'nonzero exit status: exit code: 1', C:\Users\alchemist\.cargo\registry\src\github.com-1ecc6
299db9ec823\gcc-0.1.4\src\lib.rs:125

build failed on osx, error: use of undeclared triat name `AsRef`

$ rustc --version
rustc 1.0.0-dev (92dd995e1 2015-03-16) (built 2015-03-18)
$ cargo build
Compiling gcc v0.3.3
/Users/heaven/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.3.3/src/lib.rs:113:23: 113:34 error: use of undeclared trait name AsRef
/Users/heaven/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.3.3/src/lib.rs:113 pub fn include<P: AsRef>(&mut self, dir: P) -> &mut Config {
^~~~~~~~~~~
/Users/heaven/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.3.3/src/lib.rs:125:22: 125:33 error: use of undeclared trait name AsRef
/Users/heaven/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.3.3/src/lib.rs:125 pub fn object<P: AsRef>(&mut self, obj: P) -> &mut Config {
^~~~~~~~~~~
/Users/heaven/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.3.3/src/lib.rs:137:20: 137:31 error: use of undeclared trait name AsRef
/Users/heaven/.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.3.3/src/lib.rs:137 pub fn file<P: AsRef>(&mut self, p: P) -> &mut Config {
^~~~~~~~~~~
error: aborting due to 3 previous errors
Could not compile gcc.

Build failing with the latest nightly compiler build

/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:42:3: 42:34 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:42 #[unstable(feature = "std_misc")]
                                                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:50:3: 50:34 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:50 #[unstable(feature = "std_misc")]
                                                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:57:3: 57:34 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:57 #[unstable(feature = "std_misc")]
                                                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:68:7: 68:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:68     #[unstable(feature = "std_misc")]
                                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:78:7: 78:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:78     #[unstable(feature = "std_misc")]
                                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:88:7: 88:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:88     #[unstable(feature = "std_misc")]
                                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:98:7: 98:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:98     #[unstable(feature = "std_misc")]
                                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:108:7: 108:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:108     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:119:7: 119:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:119     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:128:7: 128:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:128     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:137:7: 137:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:137     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:145:7: 145:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:145     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:154:7: 154:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:154     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:160:7: 160:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:160     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:167:7: 167:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:167     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:174:7: 174:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:174     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:180:7: 180:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:180     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:202:7: 202:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:202     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:213:7: 213:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:213     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:222:7: 222:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:222     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:230:7: 230:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:230     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:245:7: 245:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:245     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:261:7: 261:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:261     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:266:7: 266:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:266     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:271:7: 271:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:271     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:278:7: 278:38 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:278     #[unstable(feature = "std_misc")]
                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:284:3: 284:34 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:284 #[unstable(feature = "std_misc")]
                                                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:298:3: 298:34 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:298 #[unstable(feature = "std_misc")]
                                                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:313:3: 313:34 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:313 #[unstable(feature = "std_misc")]
                                                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:328:3: 328:34 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:328 #[unstable(feature = "std_misc")]
                                                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:341:3: 341:34 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:341 #[unstable(feature = "std_misc")]
                                                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:362:3: 362:46 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/duration.rs:362 #[stable(feature = "rust1", since = "1.0.0")]
                                                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/lib.rs:308:3: 308:41 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/lib.rs:308 #[deprecated = "use SteadyTime instead"]
                                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/lib.rs:308:3: 308:41 error: stability attributes may not be used outside of the standard library
/Users/uh/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.24/src/lib.rs:308 #[deprecated = "use SteadyTime instead"]

This is the version I used:

uh@macaron:~$ rustc --version
rustc 1.0.0-nightly (2baf34825 2015-04-21) (built 2015-04-21)

MSYS2 64-bit's gcc does not define `__WIN32__` by default

I'm getting an error for missing symbols in time_helpers.c:

note: D:\Git\img_dup\target\deps\libtime-040b8fe6da930644.rlib(r-time_helpers-time_helpers.o):time_helpers.c:(.text$rust_time_gmtime+0x27): undefined reference to `gmtime_r'
D:\Git\img_dup\target\deps\libtime-040b8fe6da930644.rlib(r-time_helpers-time_helpers.o):time_helpers.c:(.text$rust_time_localtime+0x27): undefined reference to `localtime_r'
ld: D:\Git\img_dup\target\deps\libtime-040b8fe6da930644.rlib(r-time_helpers-time_helpers.o): bad reloc address 0x27 in section `.text$rust_time_localtime'

This is a fresh MSYS2 install, plus gcc grabbed through the included pacman.

It looks like the C preprocessor isn't predefining __WIN32__ unless -mwin32 is passed:

$ gcc -m64 -dM -E -x c /dev/null | grep "WIN"
#define __WINT_MAX__ 4294967295U
#define __WINT_MIN__ 0U
#define __SIZEOF_WINT_T__ 4
#define __CYGWIN__ 1
#define __WINT_TYPE__ unsigned int

$ gcc -mwin32 -dM -E -x c /dev/null | grep "WIN"
#define _WIN32 1
#define __WINT_MAX__ 4294967295U
#define __WINT_MIN__ 0U
#define __WIN32 1
#define __WIN32__ 1
#define __SIZEOF_WINT_T__ 4
#define __CYGWIN__ 1
#define WIN32 1
#define __WINT_TYPE__ unsigned int
#define WINNT 1

Not sure if this belongs here or gcc-rs. Patching time to add the -mwin32 flag for target_os = "windows" did the trick, then I needed to get tchar.h from pacman -S mingw-w64-x86_64-headers and copy it into /usr/include.

Cannot build with arm-linux-androideabi

Cannot build when using the cross compiler for arm-linux-androideabi

rustc 1.0.0-dev (89c4e3792 2015-01-17 10:58:43 +0000)

   Compiling time v0.1.12
     Running `/home/nathan/Development/projects/face-blaster/target/build/time-7c7fc3eb0c12ad75/build-script-build`
Build failed, waiting for other jobs to finish...
failed to run custom build command for `time v0.1.12`
Process didn't exit successfully: `/home/nathan/Development/projects/face-blaster/target/build/time-7c7fc3eb0c12ad75/build-script-build` (status=101)
--- stdout
TARGET = Some("arm-linux-androideabi")
OPT_LEVEL = Some("0")
TARGET = Some("arm-linux-androideabi")
HOST = Some("x86_64-unknown-linux-gnu")
CC_arm-linux-androideabi = None
CC_arm_linux_androideabi = None
TARGET_CC = None
CC = None
TARGET = Some("arm-linux-androideabi")
HOST = Some("x86_64-unknown-linux-gnu")
CFLAGS_arm-linux-androideabi = None
CFLAGS_arm_linux_androideabi = None
TARGET_CFLAGS = None
CFLAGS = None
CARGO_MANIFEST_DIR = Some("/home/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.12")
OUT_DIR = Some("/home/nathan/Development/projects/face-blaster/target/arm-linux-androideabi/build/time-7c7fc3eb0c12ad75/out")
running: arm-linux-androideabi-gcc '-O0' '-c' '-ffunction-sections' '-fdata-sections' '-fPIC' '/home/nathan/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.1.12/src/time_helpers.c' '-o' '/home/nathan/Development/projects/face-blaster/target/arm-linux-androideabi/build/time-7c7fc3eb0c12ad75/out/src/time_helpers.o'

--- stderr
thread '<main>' panicked at 'failed to spawn process: no such file or directory', ../../../.cargo/registry/src/github.com-1ecc6299db9ec823/gcc-0.1.4/src/lib.rs:122

Cannot compile on windows (nightly channel)

This is the output:

$ cargo build
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling gcc v0.3.8
   Compiling libc v0.1.8
   Compiling time v0.1.26 (file:///C:/Users/Nicolas/dev/time)
failed to run custom build command for `time v0.1.26 (file:///C:/Users/Nicolas/d
ev/time)`
Process didn't exit successfully: `c:\Users\Nicolas\dev\time\target\debug\build\
time-73371842c1eccfc4\build-script-build` (exit code: 101)
--- stdout
TARGET = Some("x86_64-pc-windows-gnu")
TARGET = Some("x86_64-pc-windows-gnu")
CARGO_MANIFEST_DIR = Some("c:\\Users\\Nicolas\\dev\\time")
OUT_DIR = Some("c:\\Users\\Nicolas\\dev\\time\\target\\debug\\build\\time-733718
42c1eccfc4\\out")
OPT_LEVEL = Some("0")
PROFILE = Some("debug")
debug 0
TARGET = Some("x86_64-pc-windows-gnu")
HOST = Some("x86_64-pc-windows-gnu")
CC_x86_64-pc-windows-gnu = None
CC_x86_64_pc_windows_gnu = None
HOST_CC = None
CC = None
TARGET = Some("x86_64-pc-windows-gnu")
HOST = Some("x86_64-pc-windows-gnu")
CFLAGS_x86_64-pc-windows-gnu = None
CFLAGS_x86_64_pc_windows_gnu = None
HOST_CFLAGS = None
CFLAGS = None
TARGET = Some("x86_64-pc-windows-gnu")
HOST = Some("x86_64-pc-windows-gnu")
CC_x86_64-pc-windows-gnu = None
CC_x86_64_pc_windows_gnu = None
HOST_CC = None
CC = None
running: "gcc" "-O0" "-c" "-ffunction-sections" "-fdata-sections" "-mwin32" "-m6
4" "-fPIC" "c:\Users\Nicolas\dev\time\src/time_helpers.c" "-o" "c:\Users\Nicolas
\dev\time\target\debug\build\time-73371842c1eccfc4\out\src\time_helpers.o"


command did not execute successfully, got: exit code: 1



--- stderr
gcc: error: CreateProcess: No such file or directory
thread '<main>' panicked at 'explicit panic', c:/Users/Nicolas\.cargo\registry\s
rc\github.com-0a35038f75765ae4\gcc-0.3.8\src\lib.rs:497

formatting with alignment fails

hey, I'm learning rust and re-writing a very basic cal in order to learn. ran into a strange formatting bug:

extern crate time;

fn main() {
    // not aligned (bug in TmFmt Display impl?)
    println!("{:>11}", time::now_utc().strftime("%B").ok().unwrap());
    // aligned properly when forced into a string
    println!("{:>11}", time::now_utc().strftime("%B").ok().unwrap().to_string());
}

know what's going on here? i don't think i should have to call .to_string() in order to get the alignment...?

SteadyTime implementation/documentation is wrong.

Documentation claims

/// SteadyTimes are generated by a "steady" clock, that is, a clock which
/// never experiences discontinuous jumps and for which time always flows at
/// the same rate.

but it is implemented in terms of CLOCK_MONOTONIC on linux, which does not flow at the same rate in case NTP works or adjtime is called.

Either should use CLOCK_MONOTONIC_RAW or not claim time always flows at the same rate.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.