-
Notifications
You must be signed in to change notification settings - Fork 6
Add Timestamp component #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
166 changes: 166 additions & 0 deletions
166
components/src/main/java/org/patternfly/component/timestamp/CustomFormat.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| /* | ||
| * Copyright 2023 Red Hat | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.patternfly.component.timestamp; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| import jsinterop.annotations.JsOverlay; | ||
| import jsinterop.annotations.JsPackage; | ||
| import jsinterop.annotations.JsProperty; | ||
| import jsinterop.annotations.JsType; | ||
|
|
||
| @JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object") | ||
| public class CustomFormat implements FormatOptions { | ||
|
|
||
| @JsOverlay | ||
| public static final CustomFormat create() { | ||
| return new CustomFormat(); | ||
| } | ||
|
|
||
| @JsProperty | ||
| private String year; | ||
| @JsProperty | ||
| private String month; | ||
| @JsProperty | ||
| private String day; | ||
| @JsProperty | ||
| private String weekday; | ||
| @JsProperty | ||
| private String hour; | ||
| @JsProperty | ||
| private String minute; | ||
| @JsProperty | ||
| private String second; | ||
| @JsProperty | ||
| private String timeZone; | ||
| @JsProperty | ||
| private String timeZoneName; | ||
| @JsProperty | ||
| private Boolean hour12; | ||
| @JsProperty | ||
| private String era; | ||
| @JsProperty | ||
| private String dayPeriod; | ||
| @JsProperty | ||
| private String fractionalSecondDigits; | ||
|
|
||
| private CustomFormat() { | ||
| } | ||
|
|
||
| @JsOverlay | ||
| public final CustomFormat year(DateTimeFormatOptions.Year year) { | ||
| if (!Objects.equals(this.year, year.value)) { | ||
| this.year = year.value; | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @JsOverlay | ||
| public final CustomFormat month(DateTimeFormatOptions.Month month) { | ||
| if (!Objects.equals(this.month, month.value)) { | ||
| this.month = month.value; | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @JsOverlay | ||
| public final CustomFormat day(DateTimeFormatOptions.Day day) { | ||
| if (!Objects.equals(this.day, day.value)) { | ||
| this.day = day.value; | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @JsOverlay | ||
| public final CustomFormat weekday(DateTimeFormatOptions.Weekday weekday) { | ||
| if (!Objects.equals(this.weekday, weekday.value)) { | ||
| this.weekday = weekday.value; | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @JsOverlay | ||
| public final CustomFormat hour(DateTimeFormatOptions.Hour hour) { | ||
| if (!Objects.equals(this.hour, hour.value)) { | ||
| this.hour = hour.value; | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @JsOverlay | ||
| public final CustomFormat minute(DateTimeFormatOptions.Minute minute) { | ||
| if (!Objects.equals(this.minute, minute.value)) { | ||
| this.minute = minute.value; | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @JsOverlay | ||
| public final CustomFormat second(DateTimeFormatOptions.Second second) { | ||
| if (!Objects.equals(this.second, second.value)) { | ||
| this.second = second.value; | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @JsOverlay | ||
| public final CustomFormat timeZone(String timeZone) { | ||
| if (!Objects.equals(this.timeZone, timeZone)) { | ||
| this.timeZone = timeZone; // IANA time zone name | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @JsOverlay | ||
| public final CustomFormat timeZoneName(DateTimeFormatOptions.TimeZoneName timeZoneName) { | ||
| if (!Objects.equals(this.timeZoneName, timeZoneName.value)) { | ||
| this.timeZoneName = timeZoneName.value; | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @JsOverlay | ||
| public final CustomFormat hour12(boolean hour12) { | ||
| if (this.hour12 != hour12) { | ||
| this.hour12 = hour12; | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @JsOverlay | ||
| public final CustomFormat era(DateTimeFormatOptions.Era era) { | ||
| if (!Objects.equals(this.era, era.value)) { | ||
| this.era = era.value; | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @JsOverlay | ||
| public final CustomFormat dayPeriod(DateTimeFormatOptions.DayPeriod dayPeriod) { | ||
| if (!Objects.equals(this.dayPeriod, dayPeriod.value)) { | ||
| this.dayPeriod = dayPeriod.value; | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @JsOverlay | ||
| public final CustomFormat fractionalSecondDigits(DateTimeFormatOptions.FractionalSecondDigits digits) { | ||
| if (!Objects.equals(this.fractionalSecondDigits, digits.value)) { | ||
| this.fractionalSecondDigits = digits.value; | ||
| } | ||
| return this; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe at some point, this class and
DateTimeFormatOptionsshould be moved to Elemento. But for now it's ok to have them here.