XerShade Posted June 21, 2013 Author Share Posted June 21, 2013 A simple class I made in C# that uses Unix Time as a replacement for Environment.Tickcount.```/* * Author: XerShade * Author Website: http://www.xershade.tk/ */using System;namespace UnixTime{ /// /// Tick Count object, used to generate time related values. /// Created as a replacement for so the game's time /// does not reset when the computer running it resets. /// public sealed class TickCount { /// /// Defines a object that is created using Unix time's values. /// static DateTime _UnixTime = new DateTime(1970, 1, 1, 0, 0, 0); /// /// Generates the number of ticks since Unix Time started. /// public static Double Get { get { // Use Unix Time and DateTime.Now to calculate the value. return (DateTime.Now - TickCount._UnixTime).TotalMilliseconds; } } /// /// Generates the number of seconds since Unix Time started. /// public static Double Get { get { // Use Unix Time and DateTime.Now to calculate the value. return (DateTime.Now - TickCount._UnixTime).TotalSeconds; } } /// /// Generates the current date as a string. /// public static String GetDate { get { // Use DateTime.Now to calculate the value. return DateTime.Now.ToLongDateString(); } } /// /// Generates the current date as a short string. /// public static String GetShortDate { get { // Use DateTime.Now to calculate the value. return DateTime.Now.ToShortDateString(); } } /// /// Generates the current time as a string. /// public static String GetTime { get { // Use DateTime.Now to calculate the value. return DateTime.Now.ToLongTimeString(); } } /// /// Generates the current time as a short string. /// public static String GetShortTime { get { // Use DateTime.Now to calculate the value. return DateTime.Now.ToShortTimeString(); } } }}``` Link to comment Share on other sites More sharing options...
Daneta Posted June 22, 2013 Share Posted June 22, 2013 what does this do exactuly Link to comment Share on other sites More sharing options...
XerShade Posted June 30, 2013 Author Share Posted June 30, 2013 > what does this do exactulyApparently you can't read as I did say what it does before the code. Link to comment Share on other sites More sharing options...
Helladen Posted June 30, 2013 Share Posted June 30, 2013 > Apparently you can't read as I did say what it does before the code.He was asking what is its relevance. Link to comment Share on other sites More sharing options...
XerShade Posted July 1, 2013 Author Share Posted July 1, 2013 Well it pretty much does the same as this: [http://php.net/manual/en/function.time.php](http://php.net/manual/en/function.time.php)So these ticks if you /1000 to make them into seconds can work with php scripts. Adding another method in to get the seconds now. Link to comment Share on other sites More sharing options...
pandacoder Posted September 15, 2013 Share Posted September 15, 2013 Two 'Get' properties with different purposes, needs fixing. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now