/[projects]/dao/DaoMqPump2/DaoCommon/Time.cs
ViewVC logotype

Contents of /dao/DaoMqPump2/DaoCommon/Time.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2178 - (show annotations) (download)
Tue May 20 20:00:10 2014 UTC (10 years ago) by torben
File size: 2591 byte(s)
Test time + Timestamp
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5
6 namespace DaoCommon
7 {
8
9 public class Time
10 {
11 //Test kode til at afprøve TimeSpan og DateTime klasserne
12 public static void test()
13 {
14 try
15 {
16
17 //TimeSpan.Parse("");//Illegal string
18 //TimeSpan.Parse("sadasd"); //illegal string
19 //TimeSpan.Parse("99:99"); //Hours cannot be greater than 23
20 //TimeSpan.Parse("10:99"); //Minutes cannot be greater than 59
21 //TimeSpan.Parse("10:60"); //Minutes cannot be greater than 59
22
23 //Console.WriteLine( TimeSpan.Parse("0:0") ) ; //OK "00:00:00"
24
25 TimeSpan kl14 = TimeSpan.Parse("14:00");
26 DateTime dt1 = new DateTime(2014, 5, 20, 13, 59, 59);
27 DateTime dt2 = new DateTime(2014, 5, 20, 14, 0, 0);
28 DateTime dt3 = new DateTime(2014, 5, 20, 14, 0, 1);
29
30 Console.WriteLine("1 == " + (kl14 == dt1.TimeOfDay));
31 Console.WriteLine("1 != " + (kl14 != dt1.TimeOfDay));
32 Console.WriteLine("1 < " + (kl14 < dt1.TimeOfDay) );
33 Console.WriteLine("1 <= " + (kl14 <= dt1.TimeOfDay) );
34 Console.WriteLine("1 > " + (kl14 > dt1.TimeOfDay));
35 Console.WriteLine("1 >= " + (kl14 >= dt1.TimeOfDay));
36
37
38 Console.WriteLine("2 == " + (kl14 == dt2.TimeOfDay));
39 Console.WriteLine("2 != " + (kl14 != dt2.TimeOfDay));
40 Console.WriteLine("2 < " + (kl14 < dt2.TimeOfDay));
41 Console.WriteLine("2 <= " + (kl14 <= dt2.TimeOfDay));
42 Console.WriteLine("2 > " + (kl14 > dt2.TimeOfDay));
43 Console.WriteLine("2 >= " + (kl14 >= dt2.TimeOfDay));
44
45
46 Console.WriteLine("3 == " + (kl14 == dt3.TimeOfDay));
47 Console.WriteLine("3 != " + (kl14 != dt3.TimeOfDay));
48 Console.WriteLine("3 < " + (kl14 < dt3.TimeOfDay));
49 Console.WriteLine("3 <= " + (kl14 <= dt3.TimeOfDay));
50 Console.WriteLine("3 > " + (kl14 > dt3.TimeOfDay));
51 Console.WriteLine("3 >= " + (kl14 >= dt3.TimeOfDay));
52
53 }
54 catch (Exception e)
55 {
56 Console.WriteLine("Error: " + e.Message);
57 }
58
59 Console.WriteLine("Press any key to continue");
60 Console.ReadKey(); //wait for user input
61 }
62
63
64 }
65 }

  ViewVC Help
Powered by ViewVC 1.1.20