Skip to content

Commit fe992c9

Browse files
committed
added example app using crate
1 parent 7bf43e5 commit fe992c9

File tree

4 files changed

+362
-0
lines changed

4 files changed

+362
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ This script will:
4242

4343
The executable path should be printed in the terminal, and after 2 seconds, the program will be test run automatically.
4444

45+
## Install using cargo
46+
47+
```cargo install nepdate-cli ```
48+
Running the above command will globally install the nepdate-cli binary.
49+
50+
## using library in other applications
51+
Run the following Cargo command in your project directory:
52+
53+
```cargo add nepdate-cli```
54+
55+
Or add the following line to your Cargo.toml:
56+
57+
``` nepdate-cli = "0.1.3" ```
58+
nepdate-test-app folder has example of an application. ```use bikram::bikram::Bikram;``` should import bikram library after adding nepdate-cli dependency in application.
59+
4560
## Usage
4661

4762
After building the program, you can use it to convert dates between the two calendar systems.

nepdate-test-app/Cargo.lock

Lines changed: 310 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nepdate-test-app/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "nepdate-test"
3+
version = "0.1.1"
4+
edition = "2021"
5+
authors = ["Khumnath <[email protected]>"]
6+
7+
# Optional metadata
8+
description = "bikram sambat calendar library(nepalidate using bikram library)."
9+
license = "GPL-3.0"
10+
repository = "https://github.com/khumnath/ndate/tree/rust"
11+
12+
[dependencies]
13+
chrono = "0.4"
14+
nepdate-cli = "0.1.3"

nepdate-test-app/src/main.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use chrono::{Datelike, Local};
2+
use bikram::bikram::Bikram;
3+
fn main() {
4+
// Get today's date in NaiveDate format
5+
// Get current date
6+
let now_date = Local::now();
7+
let year = now_date.year();
8+
let month = now_date.month();
9+
let day = now_date.day();
10+
11+
let mut bsdate = Bikram::new();
12+
bsdate.from_gregorian(year, month as i32, day as i32);
13+
14+
let bs_weekday_name = bsdate.get_weekday_name(year, month as i32, day as i32);
15+
println!(
16+
" \x1b[33m Bikram Sambat: \x1b[0m \x1b[35m{} {} {} {} \x1b[33m days in bikram month: \x1b[0m{} \x1b[0m",
17+
bsdate.get_year(),
18+
bsdate.get_month(),
19+
bsdate.get_day(),
20+
bs_weekday_name,
21+
bsdate.days_in_month(bsdate.get_year(), bsdate.get_month())
22+
);
23+
}

0 commit comments

Comments
 (0)