Skip to content

Commit fbf8897

Browse files
Add more Release Date examples (#67)
1 parent 34aa300 commit fbf8897

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,35 @@
66

77
### IntelliTect.Multitool
88

9-
* ReleaseDateAttribute: Gets an UTC DateTime from compile time.
9+
* ReleaseDateAttribute: Gets an UTC DateTime from compile time. Allows us to determine the build date/time.
1010
* Example Usage:
11-
11+
12+
```cs
13+
// Simple assignment of GetReleaseDate() to a local variable
14+
DateTime? date = IntelliTect.Multitool.ReleaseDateAttribute.GetReleaseDate(); // Returns a datetime in UTC to date
15+
```
16+
1217
```cshtml
1318
// This example is in cshtml.
14-
@ReleaseDateAttribute.GetReleaseDate() // Returns a time in UTC
19+
@ReleaseDateAttribute.GetReleaseDate() // Returns a datetime in UTC
1520
```
21+
22+
```cshtml
23+
// convert this UTC DateTime object into one for my local timezone that is formatted in a “d MMM, yyyy h:mm:ss tt” (ex: 8 Feb, 2023 11:36:31 AM).
24+
// The following code will format the date and convert it to my local time zone of Pacific Standard Time.
25+
Build: @if (IntelliTect.Multitool.ReleaseDateAttribute.GetReleaseDate() is DateTime date)
26+
{
27+
@TimeZoneInfo.ConvertTimeFromUtc(date, TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time")).ToString("d MMM, yyyy h:mm:ss tt", CultureInfo.InvariantCulture)
28+
}
29+
// Result is "Build: 8 Feb, 2023 11:36:31 AM"
30+
```
1631
1732
* RepositoryPaths: Provides consistent environment-independent normalized pathing within a repository.
1833
* Example Usage:
1934
2035
```csharp
2136
// In this case, the GetDefaultRepoRoot() method can be used to get the root of a repository.
22-
string fullPathToTheFile = Path.Combine(RepositoryPaths.GetDefaultRepoRoot(), "TheFile.txt");
37+
string fullPathToTheFile = Path.Combine(IntelliTect.Multitool.RepositoryPaths.GetDefaultRepoRoot(), "TheFile.txt");
2338
```
2439

2540
### IntelliTect.Multitool.Security

0 commit comments

Comments
 (0)