Advertisement
dennoh

Greetings

Jan 3rd, 2020
620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.38 KB | None | 0 0
  1. extern crate chrono;
  2. use chrono::{Timelike, Utc};
  3.  
  4. fn main() {
  5.     println!("{}, {name}", time_of_the_day_greetings(), name="John");
  6. }
  7.  
  8. fn time_of_the_day_greetings() -> &'static str{
  9.    let now = Utc::now();
  10.    let hour = now.hour();
  11.  
  12.    if hour < 12 {
  13.        "Good morning"
  14.    } else if hour < 18 {
  15.        "Good afternoon"
  16.    } else {
  17.        "Good evening"
  18.    }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement