Skip to content

Commit

Permalink
Build and publish
Browse files Browse the repository at this point in the history
  • Loading branch information
dejanfajfar committed Nov 12, 2023
1 parent 41353e2 commit 3f6436c
Show file tree
Hide file tree
Showing 7 changed files with 289 additions and 27 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: Deploy

on:
push:
tags:
- "*" # Only run if a tag is pressent
workflow_dispatch:

jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
7.0.x
6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore -warnaserror
- name: Test
run: dotnet test --verbosity normal
Deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Tag
id: tag
run: echo "::set-output name=tag::${{ github.ref }}"
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
7.0.x
6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Pack
run: doitnet pack --output nupkgs -p:PackageVersion=${{ steps.tag.outputs.tag }} -p Configuration="Release"
- name: Publish Artifact
uses: actions/upload-artifact@v2
with:
name: Package
path: nupkgs
26 changes: 13 additions & 13 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ name: BuildAndTest

on:
push:
branches: [ "*" ]
branches: ["*"]
tags: "!*" # Do not run if tags a re pressent

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
7.0.x
6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
25 changes: 12 additions & 13 deletions .github/workflows/master_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@ name: master_pr

on:
pull_request:
branches: [ "master" ]
branches: ["master"]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
7.0.x
6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore -warnaserror
- name: Test
run: dotnet test --verbosity normal
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore -warnaserror
- name: Test
run: dotnet test --verbosity normal
70 changes: 70 additions & 0 deletions Epoch.net/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## ๐Ÿท๏ธ 4.0

### โ™ป๏ธ Changed

- Updated to .net version 7
- Moved build to github actions
- Updated code formatting to new standard

### โœจ Added

- DateOnly extensions
- TimeOnly extensions

### ๐Ÿ”ฅ Removed

- The Constants static class

## ๐Ÿท๏ธ 3.1

### โœจ Added

- LongEpochTime ToString method
- EpochTime ToString method

## ๐Ÿท๏ธ 3.0

### โœจ Added

- LongEpochTime
- EpochTime.ShortEpoch
- EpochTime.RawEpoch
- EpochTime.DateTime
- EpochTime.TimeSpan
- EpochTime.Add
- EpochValidator
- EpochTimeValueException
- ITimeProvider
- DefaultTimeProvider
- Long extensions methods

### ๐Ÿ”ฅ Removed

- EpochOverflowException
- EpochTime.AddSeconds
- EpochTime.ToRawEpoch
- EpochTime.ToDateTime
- EpochTime.ToTimeSpan

## ๐Ÿท๏ธ 2.0

### โ™ป๏ธ Changed

- Renamed the ```Epoch``` class to ```EpochTime``` to fix the name collision with the namespace.
- Updated the README.md to reflect the new naming

### ๐Ÿ› Fixed

- The name collision bug

## ๐Ÿท๏ธ 1.1

### ๐Ÿ› Fixed

* DateTime.ToRawEpoch now thrown an EpochOverflow exception if the resulting epoch is not storable in an integer
12 changes: 11 additions & 1 deletion Epoch.net/Epoch.net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,20 @@
</PropertyGroup>

<PropertyGroup>
<PackageIconUrl>https://raw.githubusercontent.com/dejanfajfar/epoch.net/master/images/logo_square_64.png</PackageIconUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageTags>posix unix timestamp epoch datetime timespan library core standard</PackageTags>
<PackageProjectUrl>https://github.com/dejanfajfar/epoch.net</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReleaseNotes>CHANGELOG.md</PackageReleaseNotes>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\"/>
<None Include="..\CHANGELOG.md" Pack="true" PackagePath="\"/>
<None Include="..\LICENSE" Pack="true" PackagePath="\"/>
<None Include="..\images\icon.png" Pack="true" PackagePath="\"/>
</ItemGroup>

</Project>
133 changes: 133 additions & 0 deletions Epoch.net/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
![](https://raw.githubusercontent.com/dejanfajfar/epoch.net/master/images/logo.png)

---

![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/dejanfajfar/epoch.net/dotnet.yml?style=flat-square)
![Nuget](https://img.shields.io/nuget/dt/epoch.net?style=flat-square&link=https%3A%2F%2Fwww.nuget.org%2Fpackages%2FEpoch.net)
![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/epoch.net?style=flat-square&link=https%3A%2F%2Fwww.nuget.org%2Fpackages%2FEpoch.net)

---

# ๐Ÿ‘‹ Introduction

> A simple and non-intrusive library for all your epoch needs
```csharp
using Epoch.net;

...
var timestamp = EpochTime.Now;
...

```

## ๐Ÿค” What is an Epoch

Epoch is shorthand for _Unix epoch time_ or as it is also known __POSIX time__.

__Short version:__ The number of seconds since __1970-01-01T00:00:00Z__ without leap seconds.

__Long version:__ [unix time](https://en.wikipedia.org/wiki/Unix_time)

## Motivation

With __.net core__ working on all major operating systems and most of them using POSIX to denote time and timestamps.
Not to mention the myriad of 3rd party tools, using POSIX time internally. The need for a working and tested implementation became clearer and clearer.
Additionally I did not want to write this logic in an inferior form in many of my applications.
So this little library was written.

Its sole purpose is to make the work with these unix timestamps as easy as possible.

For this purpose this library contains extension methods that build upon the existing __DateTime__, __TimeSpan__, __int__ and __long__ types.

# ๐Ÿ“– Glossary

| Term | Description |
|:-----|:-------------|
| EpochTime | Represents a POSIX time instance exact to the _second_ |
| EpochTimestamp | The number of seconds since 1970-01-01T00:00Z |
| LongEpochTime | Represents a POSIX time instance exact to the _millisecond_ |
| LongEpochTimestamp | The number of milliseconds since 1970-01-01T00:00Z |

## Difference between `EpochTime` and `LongEpochTime`

The initial difference was precision. _EpochTime_ will only be accurate to the nearest second on the other hand _LongEpochTime_ is accurate to the millisecond.
From this precision difference I decided to differentiate then by their __underlying__ base type.

`EpochTime` is based on `int32` / `int`

`LongEpochTime` is based on `int64` / `long`

> โ—This is sadly implies that if you get a POSIX timestamp from somewhere you, the developer, have to know if it is representing milliseconds or seconds!
## Ranges

| Unit | Min value | Max value |
|:----|----:|----:|
| EpochTimestamp | -2147483648 | 2147483647 |
| LongEpochTimestamp | -922337203685477 | 922337203685477 |

๐Ÿ“ _Note:_ The range of the `LongEpoch` is theoretically limited only by the range of `int64`.

# โœ… Features

- EpochTime a second precise POSIX time wrapper
- LongEpochTime a millisecond precise POSIX time wrapper
- Extension methods for build in time handling classes:
- DateTime
- TimeSpan
- DateOnly
- TimeOnly
- Fully tested ;)

# ๐Ÿƒโ€โ™‚๏ธ Quick start

## Add the package to yor project

The preferred way of integrating the library is to use the [nuget package](https://www.nuget.org/packages/Epoch.net). This is easily done be either:

```shell
dotnet add package Epoch.net
```

or

```shell
Install-Package Epoch.net
```

## Reference

After the package is added to the project add the using directive:

```csharp
...
using Epoch.net;
...
```

Done ๐ŸŽ‰

# ๐Ÿฆฎ Helping out

Everyone can help in their own way.

Here are just some ideas:

- Create a [ticket](https://github.com/dejanfajfar/epoch.net/issues) with a improvement suggestion
- Create a [ticket](https://github.com/dejanfajfar/epoch.net/issues) with a bug or issue you may be having
- Create a [ticket](https://github.com/dejanfajfar/epoch.net/issues) with a question that you may be having
- Have a look at the code and suggest improvements
- Spread the word of its existence
- And for the hardcore among you you can help me with the documentation ๐Ÿ˜ˆ

# ๐Ÿ”— Links

- [Changelog](https://github.com/dejanfajfar/epoch.net/blob/master/CHANGELOG.md)
- [Wiki](https://github.com/dejanfajfar/epoch.net/wiki)
- [Nuge](https://www.nuget.org/packages/Epoch.net)

# โญ๏ธ Next steps

- Consult the [Wiki](https://github.com/dejanfajfar/epoch.net/wiki)
- Create a [ticket](https://github.com/dejanfajfar/epoch.net/issues) to help the project improve
File renamed without changes

0 comments on commit 3f6436c

Please sign in to comment.