timeago/languages/
turkish.rs1use super::super::{Language, TimeUnit};
2
3#[derive(Default)]
5pub struct Turkish;
6impl Language for Turkish {
7 fn clone_boxed(&self) -> super::super::BoxedLanguage { Box::new(Self{}) }
8 fn too_low (&self) -> &'static str { "şimdi" }
9 fn too_high(&self) -> &'static str { "eski" }
10 fn ago(&self) -> &'static str { "önce" }
11 fn get_word(&self, tu: TimeUnit, _x: u64) -> &'static str {
12 use TimeUnit::*;
13 match tu {
14 Nanoseconds => "nanosaniye",
15 Microseconds => "mikrosaniye",
16 Milliseconds => "milisaniye",
17 Seconds => "saniye",
18 Minutes => "dakika",
19 Hours => "saat",
20 Days => "gün",
21 Weeks => "hafta",
22 Months => "ay",
23 Years => "yıl",
24 }
25 }
26}
27
28#[test]
29fn test() {
30 use super::super::Formatter;
31 use std::time::Duration;
32 let f = Formatter::with_language(Turkish);
33 assert_eq!(f.convert(Duration::from_secs(60)), "1 dakika önce");
34 assert_eq!(f.convert(Duration::from_secs(2)), "2 saniye önce");
35 assert_eq!(f.convert(Duration::from_secs(5)), "5 saniye önce");
36 assert_eq!(f.convert(Duration::from_secs(12)), "12 saniye önce");
37 assert_eq!(f.convert(Duration::from_secs(1*60*60)), "1 saat önce");
38 assert_eq!(f.convert(Duration::from_secs(2*60*60)), "2 saat önce");
39 assert_eq!(f.convert(Duration::from_secs(1*24*60*60)), "1 gün önce");
40 assert_eq!(f.convert(Duration::from_secs(2*24*60*60)), "2 gün önce");
41 assert_eq!(f.convert(Duration::from_secs(1*7*24*60*60)), "1 hafta önce");
42 assert_eq!(f.convert(Duration::from_secs(2*7*24*60*60)), "2 hafta önce");
43 assert_eq!(f.convert(Duration::from_secs(1*3600*12*366)), "6 ay önce");
44 assert_eq!(f.convert(Duration::from_secs(1*3600*24*366)), "1 yıl önce");
45 assert_eq!(f.convert(Duration::from_secs(2*3600*24*366)), "2 yıl önce");
46 assert_eq!(f.convert(Duration::from_secs(100*3600*24*366)), "100 yıl önce");
47 assert_eq!(f.convert(Duration::from_secs(101*3600*24*366)), "101 yıl önce");
48 assert_eq!(f.convert(Duration::from_secs(111*3600*24*366)), "111 yıl önce");
49}