8000 Date before Unix Epoch displays as 1 less day of month · Issue #30 · NativeScript/nativescript-datetimepicker · GitHub
[go: up one dir, main page]

Skip to content
Date before Unix Epoch displays as 1 less day of month #30
Open
@jorwoody

Description

@jorwoody

Which platform(s) does your issue occur on?

  • Android

Please, provide the following version numbers that your issue occurs with:

  • CLI: 5.3.1
  • Cross-platform modules: 5.3.2
  • Runtime(s): 5.3.1
  • Plugins: "dayjs": "^1.8.14",

Please, tell us how to recreate the issue in as much detail as possible.

  • Create a DatePickerField and use ngModel to bind a Date object.
  • Provide a dateFormat of "yyyy-MM-dd"
  • enter a date before Unix Epoch (such as July 11, 1961)
    ISSUE:
  • dates of certain years will display as 1 day prior to selected date
    ex. July 11, 1961 displays as July 10, 1961
    ex. July 11, 1962 displays as July 10, 1962
    ex. July 11, 1965 displays as July 10, 1965

Testing several years before 1970, it appears to happen for '61, '62, '64, '65.

NOTE:

  • entering most other years seems to work as expected...
    ex. July 11, 1963 displays as July 11, 1963
  • tested many years before 1960 and some years after 1970 with expected results

NOTE 2:

  • it seems to only affect the display value... when opening the datepicker again, the selected value is what was originally selected (ex. select July 11, 1961; shows as July 10, 1961; opening datepicker again shows July 11, 1961)

Is there any code involved?

Template:

...
<DatePickerField
	[ngModel]="dateOfBirth"
	(ngModelChange)="onDateOfBirthChanged($event)"
	[hint]="'YYYY-MM-DD' | localize"
	dateFormat="yyyy-MM-dd"
></DatePickerField>
...

Code behind:

dateOfBirth: Date = undefined
dateOfBirthString: string
...
onDateOfBirthChanged(dob: string) {
	if (!dob) {
		return
	}
	const dateObj = dayjs(dob)
	if (!dateObj.isValid()) {
		return
	}
	this.dateOfBirth = dateObj.toDate()
	this.dateOfBirthString = dateObj.format('YYYY-MM-DD')
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0