-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefs.cs
More file actions
134 lines (123 loc) · 4.38 KB
/
Copy pathDefs.cs
File metadata and controls
134 lines (123 loc) · 4.38 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2 of the License, or
// (at your option) version 3.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the
// Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
using System;
namespace libirc
{
public class Defs
{
public static readonly Version Version = new Version(1, 0, 3);
/// <summary>
/// The default nick
///
/// Change this to nick you want to have as a default for every new instance
/// of network
/// </summary>
public static string DefaultNick = "user";
public static string DefaultQuit = "Libirc - http://github.com/pidgeonproject/libirc";
public static string DefaultVersion = "Libirc v. " + Version + ", see http://pidgeonclient.org/ for more information about this library. ";
public static bool UsingProfiler = false;
public const int DefaultIRCPort = 6667;
public const int DefaultSSLIRCPort = 6697;
/// <summary>
/// Convert a date to unix one
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public static double ConvertDateToUnix(DateTime time)
{
DateTime EPOCH = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
TimeSpan span = (time - EPOCH);
return span.TotalSeconds;
}
/// <summary>
/// Convert a unix timestamp to human readable time
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public static string ConvertFromUNIXToStringSafe(string time)
{
try
{
if (time == null)
{
return "Unable to read: null";
}
double unixtimestmp = double.Parse(time);
return (new DateTime(1970, 1, 1, 0, 0, 0)).AddSeconds(unixtimestmp).ToString();
}
catch (Exception)
{
return "Unable to read: " + time;
}
}
/// <summary>
/// Convert a unix timestamp to human readable time
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public static string ConvertFromUNIXToString(string time)
{
if (time == null)
{
return null;
}
double unixtimestmp = double.Parse(time);
return (new DateTime(1970, 1, 1, 0, 0, 0)).AddSeconds(unixtimestmp).ToString();
}
/// <summary>
/// Return a DateTime object from unix time
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public static DateTime ConvertFromUNIX(string time)
{
if (time == null)
{
throw new Exception("Provided time was NULL");
}
double unixtimestmp = double.Parse(time);
return new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(unixtimestmp);
}
/// <summary>
/// Return a DateTime object from unix time
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public static DateTime ConvertFromUNIX(double time)
{
return new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(time);
}
/// <summary>
/// Priority of irc message
/// </summary>
public enum Priority
{
/// <summary>
/// High
/// </summary>
High = 8,
/// <summary>
/// Normal
/// </summary>
Normal = 2,
/// <summary>
/// Low
/// </summary>
Low = 1,
/// <summary>
/// Lowest
/// </summary>
None = 0
}
}
}