Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.02 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6.  
  7. namespace System
  8. {
  9.     public struct Time64
  10.     {
  11.         public static readonly Time64 NULL = new Time64(0);
  12.         private int int_0;
  13.         private static uint uint_0;
  14.  
  15.         public static Time64 Now
  16.         {
  17.             get
  18.             {
  19.                 return Time64.timeGetTime();
  20.             }
  21.         }
  22.  
  23.         public int TotalMilliseconds
  24.         {
  25.             get
  26.             {
  27.                 return this.int_0;
  28.             }
  29.         }
  30.  
  31.         public int Value
  32.         {
  33.             get
  34.             {
  35.                 return this.int_0;
  36.             }
  37.         }
  38.  
  39.         static Time64()
  40.         {
  41.         }
  42.  
  43.         public Time64(int Value)
  44.         {
  45.             this.int_0 = Value;
  46.         }
  47.  
  48.         public Time64(uint Value)
  49.         {
  50.             this.int_0 = (int)Value;
  51.         }
  52.  
  53.         public Time64(long Value)
  54.         {
  55.             this.int_0 = (int)Value;
  56.         }
  57.  
  58.         public static bool operator ==(Time64 t1, Time64 t2)
  59.         {
  60.             return t1.int_0 == t2.int_0;
  61.         }
  62.  
  63.         public static bool operator !=(Time64 t1, Time64 t2)
  64.         {
  65.             return t1.int_0 != t2.int_0;
  66.         }
  67.  
  68.         public static bool operator >(Time64 t1, Time64 t2)
  69.         {
  70.             return t1.int_0 > t2.int_0;
  71.         }
  72.  
  73.         public static bool operator <(Time64 t1, Time64 t2)
  74.         {
  75.             return t1.int_0 < t2.int_0;
  76.         }
  77.  
  78.         public static bool operator >=(Time64 t1, Time64 t2)
  79.         {
  80.             return t1.int_0 >= t2.int_0;
  81.         }
  82.  
  83.         public static bool operator <=(Time64 t1, Time64 t2)
  84.         {
  85.             return t1.int_0 <= t2.int_0;
  86.         }
  87.  
  88.         public static Time64 operator -(Time64 t1, Time64 t2)
  89.         {
  90.             return new Time64(t1.int_0 - t2.int_0);
  91.         }
  92.  
  93.         public Time64 AddMilliseconds(int Amount)
  94.         {
  95.             return new Time64(this.int_0 + Amount);
  96.         }
  97.  
  98.         public int AllMilliseconds()
  99.         {
  100.             return this.GetHashCode();
  101.         }
  102.  
  103.         public Time64 AddSeconds(int Amount)
  104.         {
  105.             return this.AddMilliseconds(Amount * 1000);
  106.         }
  107.  
  108.         public int AllSeconds()
  109.         {
  110.             return this.AllMilliseconds() / 1000;
  111.         }
  112.  
  113.         public Time64 AddMinutes(int Amount)
  114.         {
  115.             return this.AddSeconds(Amount * 60);
  116.         }
  117.  
  118.         public int AllMinutes()
  119.         {
  120.             return this.AllSeconds() / 60;
  121.         }
  122.  
  123.         public Time64 AddHours(int Amount)
  124.         {
  125.             return this.AddMinutes(Amount * 60);
  126.         }
  127.  
  128.         public int AllHours()
  129.         {
  130.             return this.AllMinutes() / 60;
  131.         }
  132.  
  133.         public Time64 AddDays(int Amount)
  134.         {
  135.             return this.AddHours(Amount * 24);
  136.         }
  137.  
  138.         public int AllDays()
  139.         {
  140.             return this.AllHours() / 24;
  141.         }
  142.  
  143.         public bool Next(int due = 0, int time = 0)
  144.         {
  145.             if (time == 0)
  146.                 time = Time64.timeGetTime().int_0;
  147.             return this.int_0 + due <= time;
  148.         }
  149.  
  150.         public void Set(int due, int time = 0)
  151.         {
  152.             if (time == 0)
  153.                 time = Time64.timeGetTime().int_0;
  154.             this.int_0 = time + due;
  155.         }
  156.  
  157.         public void SetSeconds(int due, int time = 0)
  158.         {
  159.             this.Set(due * 1000, time);
  160.         }
  161.  
  162.         public override bool Equals(object obj)
  163.         {
  164.             if (obj is Time64)
  165.                 return (Time64)obj == this;
  166.             else
  167.                 return base.Equals(obj);
  168.         }
  169.  
  170.         public override string ToString()
  171.         {
  172.             return this.int_0.ToString();
  173.         }
  174.  
  175.         public override int GetHashCode()
  176.         {
  177.             return this.int_0;
  178.         }
  179.  
  180.         [DllImport("winmm.dll")]
  181.         public static extern Time64 timeGetTime();
  182.     }
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement