[ACS-5858] Migrated adfMomentDateTime Pipe to date-fns equivalent (#8856)

* [ACS-5858] created adfDateTimePipe and added unit tests

* [ACS-5858] added revised unit tests

* [ACS-5858] linting fixes

* [ACS-5858] addressed review comments

* [ACS-5858] addressed review comments
This commit is contained in:
SheenaMalhotra182
2023-08-31 14:48:37 +05:30
committed by GitHub
parent bb3000346f
commit 780800453a
7 changed files with 162 additions and 0 deletions

View File

@@ -183,6 +183,7 @@ for more information about installing and using the source code.
| [Text Highlight pipe](core/pipes/text-highlight.pipe.md) | Adds highlighting to words or sections of text that match a search string. | [Source](../lib/core/src/lib/pipes/text-highlight.pipe.ts) |
| [Time Ago pipe](core/pipes/time-ago.pipe.md) | Converts a recent past date into a number of days ago. | [Source](../lib/core/src/lib/pipes/time-ago.pipe.ts) |
| [User Initial pipe](core/pipes/user-initial.pipe.md) | Takes the name fields of a UserProcessModel object and extracts and formats the initials. | [Source](../lib/core/src/lib/pipes/user-initial.pipe.ts) |
| [Date Time pipe](core/pipes/date-time.pipe.md) | Converts a given input value into a Date object and adjusts it according to the specified format and timezone offset. | [Source](../lib/core/src/lib/pipes/date-time.pipe.ts) |
### Services

View File

@@ -0,0 +1,47 @@
---
Title: Date Time Pipe
Added: v6.2.0
Status: Active
Last reviewed: 2023-08-30
---
# [Date Time Pipe](../../../lib/core/src/lib/pipes/date-time.pipe.ts "Defined in date-time.pipe.ts")
Converts a given input value into a Date object and adjusts it according to the specified format and timezone offset.
## Basic Usage
<!-- {% raw %} -->
```HTML
<div>
Adjusted Date: {{ inputValue | adfDateTime: 'your-date-format' }}
</div>
```
<!-- {% endraw %} -->
| Name | Type | Description |
| ---- | ---- | ----------- |
| value | string, Date, number | The input value to be converted to a Date object |
| dateFormat | string | The format to use for parsing the input string value |
| returns | Date | The adjusted Date object, accounted with timezone offset |
## Details
The pipe transforms the input value into a Date object, adjusting it for the timezone offset as necessary.
## Input Types
If the input value is of type string, it is parsed using the specified date format and converted to a Date object.
If the input value is a Date object, it is used as is.
If the input value is a number, it is treated as a Unix timestamp and converted to a Date object.
## Timezone Adjustment
The pipe calculates the timezone offset of the input value and adjusts it accordingly. This ensures that the resulting Date object is adjusted to the correct timezone.
## Example
```HTML
<div>
Date: {{ '2023-08-30T12:00:00' | adfDateTime: `yyyy-MM-dd'T'HH:mm:ss` }}
</div>
```

View File

@@ -52,6 +52,7 @@ backend services have been tested with each released version of ADF.
- [Search Date Range Advanced Tabbed Component](content-services/components/search-date-range-advanced-tabbed.component.md)
- [Search Filter Tabbed Component](content-services/components/search-filter-tabbed.component.md)
- [Search Facet Chip Tabbed Component](content-services/components/search-facet-chip-tabbed.md)
- [Date Time Pipe](core/pipes/date-time.pipe.md)
<!--v620 end-->