using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TiempoLocalUniversal
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void Form1_Load(object sender, EventArgs e)
{
TimeZone zona = TimeZone.CurrentTimeZone;
DateTime local = zona.ToLocalTime(DateTime.Now);
label1.Text = "La hora local es: "+ local.ToString();
DateTime universal = zona.ToUniversalTime(DateTime.Now);
label2.Text = "La hora Universal es: " + universal.ToString();
TimeZoneInfo localzona = TimeZoneInfo.Local;
label3.Text = "La Zona horaria actual es: " + localzona.DisplayName +"\r\n";
label4.Text = "Estas " + Math.Abs(localzona.BaseUtcOffset.Hours) + " hora y "
+ Math.Abs(localzona.BaseUtcOffset.Minutes) + " minutos " + "\r\n";
label5.Text = (localzona.BaseUtcOffset >= TimeSpan.Zero) ? "por delante de UTC" : "por detras de UTC";
foreach (TimeZoneInfo z in TimeZoneInfo.GetSystemTimeZones())
{
textBox2.AppendText(z.ToString()+"\r\n");
}
}
}
}
No hay comentarios:
Publicar un comentario
Nota: solo los miembros de este blog pueden publicar comentarios.