FString FDateTimeStructCustomization::ToDateTimeZoneString(const FDateTime& UTCDate)
{
	const int32 DisplayTimezone = GetLocalTimezone();
	const FDateTime LocalTime = ConvertTime(UTCDate, TIMEZONE_UTC, DisplayTimezone);
	return FString::Printf(TEXT("%s %s%0.4d"), *LocalTime.ToString(), (DisplayTimezone >= 0 ? TEXT("+") : TEXT("")), DisplayTimezone);

}
void FQosDatacenterStats::StartQosPass()
{
	if (!bAnalyticsInProgress)
	{
		FDateTime UTCTime = FDateTime::UtcNow();
		QosData.Timestamp = UTCTime.ToString();

		StartTimer(QosData.SearchTime);
		bAnalyticsInProgress = true;
	}
}
bool FBuildDataCompactifier::SafeSetTimeStamp(const FString& FilePath, FDateTime TimeStamp) const
{
	bool bSuccess = false;
	IFileManager& FileMan = IFileManager::Get();
	bSuccess = FileMan.SetTimeStamp(*FilePath, TimeStamp);
	if (bSuccess)
	{
		FDateTime ActualTimeStamp = FileMan.GetTimeStamp(*FilePath);
		int64 TickVariance = FMath::Abs(ActualTimeStamp.GetTicks() - TimeStamp.GetTicks());
		bSuccess = TickVariance < BuildDataCompactifierDefs::TimeStampTolerance;
	}
	return bSuccess;
}
void CaptureEditorData(EditorPerfCaptureParameters& OutEditorPerfStats)
{
	//Capture the current time stamp and format it to YYYY-MM-DD HH:MM:SS.mmm.
	FDateTime CurrentDateAndTime = FDateTime::UtcNow();
	
	//Find the Average FPS
	//Clamp to avoid huge averages at startup or after hitches
	const float CurrentFPS = 1.0f / FSlateApplication::Get().GetAverageDeltaTime();
	const float ClampedFPS = (CurrentFPS < 0.0f || CurrentFPS > 4000.0f) ? 0.0f : CurrentFPS;
	OutEditorPerfStats.AverageFPS.Add(ClampedFPS);

	//Find the Frame Time in ms.
	//Clamp to avoid huge averages at startup or after hitches
	const float AverageMS = FSlateApplication::Get().GetAverageDeltaTime() * 1000.0f;
	const float ClampedMS = (AverageMS < 0.0f || AverageMS > 4000.0f) ? 0.0f : AverageMS;
	OutEditorPerfStats.AverageFrameTime.Add(ClampedMS);

	//Query OS for process memory used.
	FPlatformMemoryStats MemoryStats = FPlatformMemory::GetStats();
	OutEditorPerfStats.UsedPhysical.Add((float)MemoryStats.UsedPhysical / 1024);

	//Query OS for available physical memory
	OutEditorPerfStats.AvailablePhysical.Add((float)MemoryStats.AvailablePhysical / 1024);

	//Query OS for available virtual memory
	OutEditorPerfStats.AvailableVirtual.Add((float)MemoryStats.AvailableVirtual / 1024);

	//Query OS for used virtual memory
	OutEditorPerfStats.UsedVirtual.Add((float)MemoryStats.UsedVirtual / 1024);

	//Query OS for used Peak Used physical memory
	OutEditorPerfStats.PeakUsedPhysical.Add((float)MemoryStats.PeakUsedPhysical / 1024);

	//Query OS for used Peak Used virtual memory
	OutEditorPerfStats.PeakUsedVirtual.Add((float)MemoryStats.PeakUsedVirtual / 1024);

	//Capture the time stamp.
	FString FormatedTimeStamp = FString::Printf(TEXT("%04i-%02i-%02i %02i:%02i:%02i.%03i"), CurrentDateAndTime.GetYear(), CurrentDateAndTime.GetMonth(), CurrentDateAndTime.GetDay(), CurrentDateAndTime.GetHour(), CurrentDateAndTime.GetMinute(), CurrentDateAndTime.GetSecond(), CurrentDateAndTime.GetMillisecond());
	OutEditorPerfStats.FormattedTimeStamp.Add(FormatedTimeStamp);
	OutEditorPerfStats.TimeStamp.Add(CurrentDateAndTime);

}
Example #5
0
FTimeDate ATimeManager::ConvertToTimeDate(FDateTime dt)
{
    return FTimeDate(dt.GetYear(), dt.GetMonth(), dt.GetDay(), dt.GetHour(), dt.GetMinute(), dt.GetSecond(), dt.GetMillisecond());
}
Example #6
0
bool UKismetMathLibrary::IsMorning( FDateTime A )
{
	return A.IsMorning();
}
Example #7
0
bool UKismetMathLibrary::IsAfternoon( FDateTime A )
{
	return A.IsAfternoon();
}
Example #8
0
int32 UKismetMathLibrary::GetYear( FDateTime A )
{
	return A.GetYear();
}
Example #9
0
FTimespan UKismetMathLibrary::GetTimeOfDay( FDateTime A )
{
	return A.GetTimeOfDay();
}
Example #10
0
int32 UKismetMathLibrary::GetSecond( FDateTime A )
{
	return A.GetSecond();
}
	static FString TimestampToString(FDateTime InTimestamp)
	{
		return LexicalConversion::ToString(InTimestamp.ToUnixTimestamp());
	}
Example #12
0
int32 UKismetMathLibrary::GetMinute( FDateTime A )
{
	return A.GetMinute();
}
Example #13
0
int32 UKismetMathLibrary::GetHour12( FDateTime A )
{
	return A.GetHour12();
}
Example #14
0
int32 UKismetMathLibrary::GetDay( FDateTime A )
{
	return A.GetDay();
}
Example #15
0
FDateTime UKismetMathLibrary::GetDate( FDateTime A )
{
	return A.GetDate();
}
// cooked package asset registry saves information about all the cooked packages and assets contained within for stats purposes
// in json format
bool FChunkManifestGenerator::SaveCookedPackageAssetRegistry( const FString& SandboxCookedRegistryFilename, const bool Append )
{
	bool bSuccess = false;
	for ( const auto& Platform : Platforms )
	{
		TSet<FName> CookedPackages;

		// save the file 
		const FString CookedAssetRegistryFilename = SandboxCookedRegistryFilename.Replace(TEXT("[Platform]"), *Platform->PlatformName());

		FString JsonOutString;
		JsonWriter Json = TJsonWriterFactory<TCHAR, TPrettyJsonPrintPolicy<TCHAR> >::Create(&JsonOutString);

		Json->WriteObjectStart();
		Json->WriteArrayStart(TEXT("Packages"));

		for ( const auto& Package : AllCookedPackages )
		{
			Json->WriteObjectStart(); // unnamed package start
			const FName& PackageName = Package.Key;
			const FString& SandboxPath = Package.Value;

			CookedPackages.Add( PackageName );

			FString PlatformSandboxPath = SandboxPath.Replace(TEXT("[Platform]"), *Platform->PlatformName());
			
			FDateTime TimeStamp = IFileManager::Get().GetTimeStamp( *PlatformSandboxPath );

			Json->WriteValue( "SourcePackageName", PackageName.ToString() );
			Json->WriteValue( "CookedPackageName", PlatformSandboxPath );
			Json->WriteValue( "CookedPackageTimeStamp", TimeStamp.ToString() );
			
			Json->WriteArrayStart("AssetData");
			for (const auto& AssetData : AssetRegistryData)
			{	// Add only assets that have actually been cooked and belong to any chunk
				if (AssetData.ChunkIDs.Num() > 0 && (AssetData.PackageName == PackageName))
				{
					Json->WriteObjectStart();
					// save all their infos 
					Json->WriteValue(TEXT("ObjectPath"), AssetData.ObjectPath.ToString() );
					Json->WriteValue(TEXT("PackageName"), AssetData.PackageName.ToString() );
					Json->WriteValue(TEXT("PackagePath"), AssetData.PackagePath.ToString() );
					Json->WriteValue(TEXT("GroupNames"), AssetData.GroupNames.ToString() );
					Json->WriteValue(TEXT("AssetName"), AssetData.AssetName.ToString() );
					Json->WriteValue(TEXT("AssetClass"), AssetData.AssetClass.ToString() );
					Json->WriteObjectStart("TagsAndValues");
					for ( const auto& Tag : AssetData.TagsAndValues )
					{
						Json->WriteValue( Tag.Key.ToString(), Tag.Value );
					}
					Json->WriteObjectEnd(); // end tags and values object
					Json->WriteObjectEnd(); // end unnamed array object
				}
			}
			Json->WriteArrayEnd();
			Json->WriteObjectEnd(); // unnamed package
		}

		if ( Append )
		{
			FString JsonInString;
			if ( FFileHelper::LoadFileToString(JsonInString, *CookedAssetRegistryFilename) )
			{
				// load up previous package asset registry and fill in any packages which weren't recooked on this run
				JsonReader Reader = TJsonReaderFactory<TCHAR>::Create(JsonInString);
				TSharedPtr<FJsonObject> JsonObject;
				bool shouldRead = FJsonSerializer::Deserialize(Reader, JsonObject) && JsonObject.IsValid() && JsonObject->HasTypedField<EJson::Array>(TEXT("Packages"));
				if ( shouldRead )
				{
					TArray<TSharedPtr<FJsonValue>> PackageList = JsonObject->GetArrayField(TEXT("Packages"));
					for (auto PackageListIt = PackageList.CreateConstIterator(); PackageListIt && shouldRead; ++PackageListIt)
					{
						const TSharedPtr<FJsonValue>& JsonValue = *PackageListIt;
						shouldRead = JsonValue->Type == EJson::Object;
						if ( shouldRead )
						{
							const TSharedPtr<FJsonObject>& JsonPackage = JsonValue->AsObject();

							// get the package name and see if we have already written it out this run
							
							FString CookedPackageName;
							verify( JsonPackage->TryGetStringField(TEXT("SourcePackageName"), CookedPackageName) );

							const FName CookedPackageFName(*CookedPackageName);
							if ( CookedPackages.Contains(CookedPackageFName))
							{
								// don't need to process this package
								continue;
							}


							// check that the on disk version is still valid
							FString SourcePackageName;
							check( JsonPackage->TryGetStringField( TEXT("SourcePackageName"), SourcePackageName) );

							// if our timestamp is different then don't copy the information over
							FDateTime CurrentTimeStamp = IFileManager::Get().GetTimeStamp( *CookedPackageName );

							FString SavedTimeString;
							check( JsonPackage->TryGetStringField(TEXT("CookedPackageTimeStamp"), SavedTimeString) );
							FDateTime SavedTimeStamp;
							FDateTime::Parse(SavedTimeString, SavedTimeStamp);

							if ( SavedTimeStamp != CurrentTimeStamp )
							{
								continue;
							}



							CopyJsonValueToWriter(Json, FString(), JsonValue);
							// read in all the other stuff and copy it over to the new registry
							/*Json->WriteObjectStart(); // open package

							// copy all the values over
							for ( const auto& JsonPackageValue : JsonPackage->Values)
							{
								CopyJsonValueToWriter(Json, JsonPackageValue.Key, JsonPackageValue.Value);
							}

							Json->WriteObjectEnd();*/
						}
						
					}
				}
				else
				{
					UE_LOG(LogChunkManifestGenerator, Warning, TEXT("Unable to read or json is invalid format %s"), *CookedAssetRegistryFilename);
				}
			}
		}


		Json->WriteArrayEnd();
		Json->WriteObjectEnd();

		if (Json->Close())
		{
			FArchive* ItemTemplatesFile = IFileManager::Get().CreateFileWriter(*CookedAssetRegistryFilename);
			if (ItemTemplatesFile)
			{
				// serialize the file contents
				TStringConversion<FTCHARToUTF8_Convert> Convert(*JsonOutString);
				ItemTemplatesFile->Serialize(const_cast<ANSICHAR*>(Convert.Get()), Convert.Length());
				ItemTemplatesFile->Close();
				if ( !ItemTemplatesFile->IsError() )
				{
					bSuccess = true;
				}
				else
				{
					UE_LOG(LogChunkManifestGenerator, Error, TEXT("Unable to write to %s"), *CookedAssetRegistryFilename);
				}
				delete ItemTemplatesFile;
			}
			else
			{
				UE_LOG(LogChunkManifestGenerator, Error, TEXT("Unable to open %s for writing."), *CookedAssetRegistryFilename);
			}
		}
		else
		{
			UE_LOG(LogChunkManifestGenerator, Error, TEXT("Error closing Json Writer"));
		}
	}
	return bSuccess;
}
Example #17
0
FText FText::AsDateTime( const FDateTime& DateTime, const EDateTimeStyle::Type DateStyle, const EDateTimeStyle::Type TimeStyle, const FString& TimeZone, const FCulturePtr& TargetCulture )
{
	checkf(FInternationalization::Get().IsInitialized() == true, TEXT("FInternationalization is not initialized. An FText formatting method was likely used in static object initialization - this is not supported."));
	return FText::FromString(DateTime.ToString(TEXT("%Y.%m.%d-%H.%M.%S")));
}
Example #18
0
int32 UKismetMathLibrary::GetMonth( FDateTime A )
{
	return A.GetMonth();
}