-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimeZone.cs
50 lines (39 loc) · 1.57 KB
/
TimeZone.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Globalization;
class TimeZoneDemo
{
static void Main( )
{
Console.WriteLine("_________________");
/////////////////////////
const string dataFmt = "{0,-30}{1}";
const string timeFmt = "{0,-30}{1:yyyy-MM-dd HH:mm}";
/////////////////////////
// Hakee ajan ja nyky hetkisen pv.kk.yyyy
TimeZone localZone = TimeZone.CurrentTimeZone;
DateTime currentDate = DateTime.Now;
int currentYear = currentDate.Year;
// Etsii koordinoitu yleisajan eli UTC
// aika vyöhyke.
Console.WriteLine( dataFmt, "Standard time name:",
localZone.StandardName );
Console.WriteLine( dataFmt, "Daylight saving time name:",
localZone.DaylightName );
Console.WriteLine("_________________");
// Tulostaa nyky ajan ja hetkisen aika
// sekä onko kesä-vai talviaika, vain totta vai taru
Console.WriteLine( "\n" + timeFmt, "Current date and time:",
currentDate );
Console.WriteLine( dataFmt, "Daylight saving time?",
localZone.IsDaylightSavingTime( currentDate ) );
///
DateTime currentUTC =
localZone.ToUniversalTime( currentDate );
TimeSpan currentOffset =
localZone.GetUtcOffset( currentDate );
//Uusi tulostus, että tänään on pälä pälä....
DaylightTime daylight =
localZone.GetDaylightChanges( currentYear );
Console.WriteLine("\n Tänään on: " + currentYear + "\t" + currentUTC + "\n");
}
}