From 11b2a10247bcfb5b06ba051368642238c9eb4ecb Mon Sep 17 00:00:00 2001 From: Kang Seonghoon Date: Sat, 12 Jul 2014 23:41:22 +0900 Subject: [PATCH] added Cargo support and updated .travis.yml; language changes: ToStr -> ToString. --- .gitignore | 14 +------------- .travis.yml | 18 ++++++++++-------- Cargo.toml | 10 ++++++++++ Makefile.in | 33 --------------------------------- configure | 4 ---- src/chrono/date.rs | 8 ++++---- src/chrono/duration.rs | 16 ++++++++-------- src/chrono/lib.rs | 2 -- src/chrono/time.rs | 10 +++++----- 9 files changed, 38 insertions(+), 77 deletions(-) create mode 100644 Cargo.toml delete mode 100644 Makefile.in delete mode 100755 configure diff --git a/.gitignore b/.gitignore index be20a11..2b0e81e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,2 @@ -*~ -*# -*.o -*.so -*.dylib -*.dSYM -*.dll -*.rlib -*.dummy -*.exe -build -Makefile -*-test doc +target diff --git a/.travis.yml b/.travis.yml index e73f9d9..2486ff1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,20 @@ env: global: - secure: i8Ijk6g4/26e3e7+r2OeGAPSP8G8O9P50JibW1omJ0j0ixXhyhPoY2bch3CGhnOu44dI5O31IIbjJJ+iEMp29xQBvkv9YpxAI+hIzOP+XAH6GCYxUDiBVcDoWrXTj+wU6/veuvjLCunu4eRHlskrgJbZXhUVODYzJuLgsN8Ou0w= -#before_install: +before_install: # - yes | sudo add-apt-repository ppa:hansjorg/rust # - sudo apt-get update -install: - - curl -O http://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz - - tar xfz rust-nightly-x86_64-unknown-linux-gnu.tar.gz - - (cd rust-nightly-x86_64-unknown-linux-gnu/ && sudo ./install.sh) # - sudo apt-get install rust-nightly + - curl -O http://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz + - curl -O http://static.rust-lang.org/cargo-dist/cargo-nightly-linux.tar.gz + - tar xfz rust-nightly-x86_64-unknown-linux-gnu.tar.gz + - (cd rust-nightly-x86_64-unknown-linux-gnu/ && sudo ./install.sh --prefix=/usr) + - tar xfz cargo-nightly-linux.tar.gz + - sudo cp -R cargo-nightly/* /usr script: - - ./configure - - make check RUSTFLAGS= - - make doc + - cargo build + - cargo test + - rustdoc src/chrono/lib.rs branches: only: - master diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e90c25d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] + +name = "chrono" +version = "0.1.0" +authors = ["Kang Seonghoon "] + +[[lib]] + +name = "chrono" +path = "src/chrono/lib.rs" diff --git a/Makefile.in b/Makefile.in deleted file mode 100644 index 8aa625b..0000000 --- a/Makefile.in +++ /dev/null @@ -1,33 +0,0 @@ -VPATH=%VPATH% - -CC ?= gcc -CXX ?= g++ -CXXFLAGS ?= -AR ?= ar -RUSTC ?= rustc -RUSTDOC ?= rustdoc -RUSTFLAGS ?= -O - -LIB_RS = src/chrono/lib.rs -RUST_SRC = $(shell find $(VPATH)/src/chrono -type f -name '*.rs') - -.PHONY: all -all: libchrono.dummy - -libchrono.dummy: $(LIB_RS) $(RUST_SRC) - $(RUSTC) $(RUSTFLAGS) $< --out-dir . - touch $@ - -chrono-test: $(LIB_RS) $(RUST_SRC) - $(RUSTC) $(RUSTFLAGS) $< -o $@ --test - -check: chrono-test - ./chrono-test - -doc: $(LIB_RS) $(RUST_SRC) - $(RUSTDOC) $(LIB_RS) - -.PHONY: clean -clean: - rm -f *.o *.a *.so *.dylib *.rlib *.dll *.dummy *.exe *-test - diff --git a/configure b/configure deleted file mode 100755 index 62a0f4c..0000000 --- a/configure +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -SRCDIR="$(cd $(dirname $0) && pwd)" -sed "s#%VPATH%#${SRCDIR}#" ${SRCDIR}/Makefile.in > Makefile diff --git a/src/chrono/date.rs b/src/chrono/date.rs index 3908417..54a991e 100644 --- a/src/chrono/date.rs +++ b/src/chrono/date.rs @@ -701,10 +701,10 @@ mod tests { #[test] fn test_date_fmt() { - assert_eq!(DateZ::from_ymd(2012, 3, 4).unwrap().to_str(), "2012-03-04".to_string()); - assert_eq!(DateZ::from_ymd(0, 3, 4).unwrap().to_str(), "0000-03-04".to_string()); - assert_eq!(DateZ::from_ymd(-307, 3, 4).unwrap().to_str(), "-0307-03-04".to_string()); - assert_eq!(DateZ::from_ymd(12345, 3, 4).unwrap().to_str(), "+12345-03-04".to_string()); + assert_eq!(DateZ::from_ymd(2012, 3, 4).unwrap().to_string(), "2012-03-04".to_string()); + assert_eq!(DateZ::from_ymd(0, 3, 4).unwrap().to_string(), "0000-03-04".to_string()); + assert_eq!(DateZ::from_ymd(-307, 3, 4).unwrap().to_string(), "-0307-03-04".to_string()); + assert_eq!(DateZ::from_ymd(12345, 3, 4).unwrap().to_string(), "+12345-03-04".to_string()); } } diff --git a/src/chrono/duration.rs b/src/chrono/duration.rs index b0c7a28..ea22639 100644 --- a/src/chrono/duration.rs +++ b/src/chrono/duration.rs @@ -399,14 +399,14 @@ mod tests { #[test] fn test_duration_fmt() { - assert_eq!(Duration::zero().to_str(), "PT0S".to_string()); - assert_eq!(Duration::days(42).to_str(), "P42D".to_string()); - assert_eq!(Duration::days(-42).to_str(), "P-42D".to_string()); - assert_eq!(Duration::seconds(42).to_str(), "PT42S".to_string()); - assert_eq!(Duration::milliseconds(42).to_str(), "PT0,042S".to_string()); - assert_eq!(Duration::microseconds(42).to_str(), "PT0,000042S".to_string()); - assert_eq!(Duration::nanoseconds(42).to_str(), "PT0,000000042S".to_string()); - assert_eq!((Duration::days(7) + Duration::milliseconds(6543)).to_str(), + assert_eq!(Duration::zero().to_string(), "PT0S".to_string()); + assert_eq!(Duration::days(42).to_string(), "P42D".to_string()); + assert_eq!(Duration::days(-42).to_string(), "P-42D".to_string()); + assert_eq!(Duration::seconds(42).to_string(), "PT42S".to_string()); + assert_eq!(Duration::milliseconds(42).to_string(), "PT0,042S".to_string()); + assert_eq!(Duration::microseconds(42).to_string(), "PT0,000042S".to_string()); + assert_eq!(Duration::nanoseconds(42).to_string(), "PT0,000000042S".to_string()); + assert_eq!((Duration::days(7) + Duration::milliseconds(6543)).to_string(), "P7DT6,543S".to_string()); } } diff --git a/src/chrono/lib.rs b/src/chrono/lib.rs index 6986ca2..7d55f2f 100644 --- a/src/chrono/lib.rs +++ b/src/chrono/lib.rs @@ -2,8 +2,6 @@ // Copyright (c) 2014, Kang Seonghoon. // See README.md and LICENSE.txt for details. -#![crate_id = "chrono#0.1.0"] -#![crate_type = "lib"] #![comment = "Date and time library for Rust"] #![license = "MIT"] diff --git a/src/chrono/time.rs b/src/chrono/time.rs index d560e57..b09cdd4 100644 --- a/src/chrono/time.rs +++ b/src/chrono/time.rs @@ -258,12 +258,12 @@ mod tests { #[test] fn test_time_fmt() { - assert_eq!(hmsm(23, 59, 59, 999).to_str(), "23:59:59,999".to_string()); - assert_eq!(hmsm(23, 59, 59, 1_000).to_str(), "23:59:60".to_string()); - assert_eq!(hmsm(23, 59, 59, 1_001).to_str(), "23:59:60,001".to_string()); - assert_eq!(TimeZ::from_hms_micro(0, 0, 0, 43210).unwrap().to_str(), + assert_eq!(hmsm(23, 59, 59, 999).to_string(), "23:59:59,999".to_string()); + assert_eq!(hmsm(23, 59, 59, 1_000).to_string(), "23:59:60".to_string()); + assert_eq!(hmsm(23, 59, 59, 1_001).to_string(), "23:59:60,001".to_string()); + assert_eq!(TimeZ::from_hms_micro(0, 0, 0, 43210).unwrap().to_string(), "00:00:00,043210".to_string()); - assert_eq!(TimeZ::from_hms_nano(0, 0, 0, 6543210).unwrap().to_str(), + assert_eq!(TimeZ::from_hms_nano(0, 0, 0, 6543210).unwrap().to_string(), "00:00:00,006543210".to_string()); } }