本文整理汇总了C#中System.DateTime.ToUnixTimestamp方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.ToUnixTimestamp方法的具体用法?C# DateTime.ToUnixTimestamp怎么用?C# DateTime.ToUnixTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.ToUnixTimestamp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StatsGetPhotostreamReferrers
public StatReferrerCollection StatsGetPhotostreamReferrers(DateTime date, string domain, int perPage, int page)
{
var dictionary = new Dictionary<string, string>();
dictionary.Add("method", "flickr.stats.getPhotostreamReferrers");
dictionary.Add("date", date.ToUnixTimestamp());
dictionary.Add("domain", domain);
if (perPage != 0) dictionary.Add("per_page", perPage.ToString(CultureInfo.InvariantCulture));
if (page != 0) dictionary.Add("page", page.ToString(CultureInfo.InvariantCulture));
return GetResponse<StatReferrerCollection>(dictionary);
}
示例2: ToUnixTimestamp_LocalTimeValues
public void ToUnixTimestamp_LocalTimeValues(int year, int month, int day, double expectedResult)
{
// Arrange
var given = new DateTime(year, month, day);
// Act, Assert
given.ToUnixTimestamp().Should().Be(expectedResult);
}
示例3: StatsGetPhotostreamStats
public Stats StatsGetPhotostreamStats(DateTime date)
{
var dictionary = new Dictionary<string, string>();
dictionary.Add("method", "flickr.stats.getPhotostreamStats");
dictionary.Add("date", date.ToUnixTimestamp());
return GetResponse<Stats>(dictionary);
}
示例4: StatsGetPhotosetDomains
public StatDomainCollection StatsGetPhotosetDomains(DateTime date, string photosetId, int page, int perPage)
{
var dictionary = new Dictionary<string, string>();
dictionary.Add("method", "flickr.stats.getPhotosetDomains");
dictionary.Add("date", date.ToUnixTimestamp());
if (photosetId != null) dictionary.Add("photoset_id", photosetId);
if (page != 0) dictionary.Add("page", page.ToString(CultureInfo.InvariantCulture));
if (perPage != 0) dictionary.Add("per_page", perPage.ToString(CultureInfo.InvariantCulture));
return GetResponse<StatDomainCollection>(dictionary);
}
示例5: StatsGetCollectionStats
public Stats StatsGetCollectionStats(DateTime date, string collectionId)
{
var dictionary = new Dictionary<string, string>();
dictionary.Add("method", "flickr.stats.getCollectionStats");
dictionary.Add("date", date.ToUnixTimestamp());
dictionary.Add("collection_id", collectionId);
return GetResponse<Stats>(dictionary);
}
示例6: PhotosRecentlyUpdated
public PhotoCollection PhotosRecentlyUpdated(DateTime minDate, PhotoSearchExtras extras, int page, int perPage)
{
var dictionary = new Dictionary<string, string>();
dictionary.Add("method", "flickr.photos.recentlyUpdated");
dictionary.Add("min_date", minDate.ToUnixTimestamp());
if (extras != PhotoSearchExtras.None) dictionary.Add("extras", UtilityMethods.ExtrasToString(extras));
if (page != 0) dictionary.Add("page", page.ToString(CultureInfo.InvariantCulture));
if (perPage != 0) dictionary.Add("per_page", perPage.ToString(CultureInfo.InvariantCulture));
return GetResponse<PhotoCollection>(dictionary);
}
示例7: byCreatedAt
protected void byCreatedAt(DateTime startCreatedAt, DateTime endCreatedAt)
{
this.createdAt = String.Format("{0}-{1}", startCreatedAt.ToUnixTimestamp(), endCreatedAt.ToUnixTimestamp());
}
示例8: ExpireAtCommand
public ExpireAtCommand(String key, DateTime expiration) :
this(key, expiration.ToUnixTimestamp())
{
}
示例9: GetCoinFlow
public FlowDataView GetCoinFlow(string game, AWSRegion region, DateTime start, DateTime end)
{
GameMonitoringConfig GameToGet = Games.Instance.GetMonitoredGames().Where(x => x.ShortTitle == game).FirstOrDefault();
FlowDataView chart = new FlowDataView() {
Inflows = GetFlowData(GameToGet.Id, TransactionType.AddCredits, start, end),
Outflows = GetFlowData(GameToGet.Id, TransactionType.Purchase, start, end),
StartDate = start.ToUnixTimestamp() * 1000
};
return chart;
}
示例10: AddIpBan
public async Task AddIpBan(string ip, DateTime bandate, DateTime unbandate, string bannedby, string banreason)
{
await ExecuteNonQuery("INSERT INTO `ip_banned` (ip, bandate, unbandate, bannedby, banreason) VALUES (@ip, @bandate, @unbandate, @bannedby, @banreason)",
new MySqlParameter("@ip", ip), new MySqlParameter("@bandate", bandate.ToUnixTimestamp()), new MySqlParameter("@unbandate", unbandate.ToUnixTimestamp()),
new MySqlParameter("@bannedby", bannedby), new MySqlParameter("@banreason", banreason));
}
示例11: ToUnixTimeStampTest
public void ToUnixTimeStampTest()
{
var testDate = new DateTime(2014, 1, 1);
const long expectedTimestamp = 1388534400;
Assert.Equal(expectedTimestamp, testDate.ToUnixTimestamp());
}
示例12: Snapshot
/// <summary>
/// Initializes a new Snapshot, with the specified Date it was Posted
/// </summary>
/// <param name="Snapshot">The snapshot source</param>
/// <param name="Date">The original date in which this snapshot was created</param>
public Snapshot(string Snapshot, DateTime Date, StatsDatabase Database)
{
// Load out database connection
this.Driver = Database;
this.Date = Date;
this.TimeStamp = Date.ToUnixTimestamp();
// Get our snapshot key value pairs
string[] Data = Snapshot.Split('\\');
Snapshot = null;
// Check for invalid snapshot string. All snapshots have at least 36 data pairs,
// and has an Even number of data sectors. We must also have an "End of File" Sector
if (Data.Length < 36 || Data.Length % 2 != 0 || !Data.Contains("EOF"))
{
IsValid = false;
return;
}
// Define if we are central update. the "cdb_update" variable must be the LAST sector in snapshot
this.IsCentralUpdate = (Data[Data.Length - 2] == "cdb_update" && Data[Data.Length - 1] == "1");
// Server data
this.ServerPrefix = Data[0];
this.ServerName = Data[1];
this.ServerPort = int.Parse(Data[3].ToString());
this.QueryPort = int.Parse(Data[5].ToString());
// Map Data
this.MapName = Data[7];
this.MapId = int.Parse(Data[9]);
this.MapStart = (int)Convert.ToDouble(Data[11], CultureInfo.InvariantCulture.NumberFormat);
this.MapEnd = (int)Convert.ToDouble(Data[13], CultureInfo.InvariantCulture.NumberFormat);
// Misc Data
this.WinningTeam = int.Parse(Data[15]);
this.GameMode = int.Parse(Data[17]);
this.Mod = Data[21];
this.PlayersConnected = int.Parse(Data[23]);
// Army Data
this.WinningArmy = int.Parse(Data[25]);
this.Team1Army = int.Parse(Data[27]);
this.Team1Tickets = int.Parse(Data[29]);
this.Team2Army = int.Parse(Data[31]);
this.Team2Tickets = int.Parse(Data[33]);
// Setup snapshot variables
PlayerData = new Dictionary<int, Dictionary<string, string>>();
KillData = new Dictionary<int, Dictionary<string, string>>();
// Check for custom map, with no ID
if (MapId == 99)
{
IsCustomMap = true;
// Check for existing map data
List<Dictionary<string, object>> Rows = Driver.Query("SELECT id FROM mapinfo WHERE [email protected]", MapName);
if (Rows.Count == 0)
{
// Create new MapId. Id's 700 - 1000 are reserved for unknown maps in the Constants.py file
// There should never be more then 300 unknown map id's, considering 1001 is the start of KNOWN
// Custom mod map id's
Rows = Driver.Query("SELECT COALESCE(MAX(id), 699) AS id FROM mapinfo WHERE id BETWEEN 700 AND 1000");
MapId = Int32.Parse(Rows[0]["id"].ToString()) + 1;
// Insert map data, so we dont lose this mapid we generated
Driver.Execute("INSERT INTO mapinfo(id, name) VALUES (@P0, @P1)", MapId, MapName);
}
else
MapId = Int32.Parse(Rows[0]["id"].ToString());
}
else
IsCustomMap = (MapId >= 700);
// Do player snapshots, sector 36 is first player
for (int i = 36; i < Data.Length; i += 2)
{
// Format: "DataKey_PlayerId". PlayerId is not the PID, but rather
// the player INDEX
string[] Parts = Data[i].Split('_');
// Ignore uncomplete snapshots
if (Parts.Length == 1)
{
// Unless we are at the end of file, IF there is no PID
// Given for an item, the snapshot is invalid!
if (Parts[0] == "EOF")
break;
else
IsValid = false;
return;
}
// If the item key is "pID", then we have a new player record
//.........这里部分代码省略.........
示例13: byUpdatedAt
protected void byUpdatedAt(DateTime startUpdatedAt, DateTime endUpdatedAt)
{
this.updatedAt = String.Format("{0}-{1}", startUpdatedAt.ToUnixTimestamp(), endUpdatedAt.ToUnixTimestamp());
}
示例14: Edit
public bool Edit(string name, DateTime dateOfStart, DateTime dateOfEnd, Teacher teacher, IRoom room, Group group)
{
if (EditReservation(Ptr, name, dateOfStart.ToUnixTimestamp(), dateOfEnd.ToUnixTimestamp(), teacher.Ptr, room.Ptr, group.Ptr))
{
Teacher = App.Teachers.SingleOrDefault(x => x.Ptr == GetReservationTeacher(Ptr));
Room = App.Rooms.SingleOrDefault(x => x.Ptr == GetReservationRoom(Ptr));
Group = App.Groups.SingleOrDefault(x => x.Ptr == GetReservationGroup(Ptr));
OnPropertyChanged("Name");
OnPropertyChanged("DateOfStart");
OnPropertyChanged("DateOfEnd");
InvokePropertyChanged();
return true;
}
return false;
}
示例15: GetCoinFlowByCat
public FlowDataView GetCoinFlowByCat(GameMonitoringConfig game, AWSRegion region, DateTime start, DateTime end)
{
FlowDataView chart = new FlowDataView()
{
Inflows = GetFlowDataByCategory(game.Id, TransactionType.AddCredits, start, end),
Outflows = GetFlowDataByCategory(game.Id, TransactionType.Purchase, start, end),
StartDate = start.ToUnixTimestamp() * 1000
};
return chart;
}