Skip to content

Display custom date format not supported by moment in datepicker #2236

@XcrossD

Description

@XcrossD
  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

I'm trying to implement lunar calendar with datepicker, but obviously moment does not support the formatting of lunar calendar dates. It would be great to accept a function to render custom date strings in the input, instead of relying on moment.format().

Example: 2020-05-13 turns into 庚子年(鼠)四月廿一

Please suggest other possible solutions if this proposal is not considered. However, seeing that we could customize date cells with the dateRender option I think it makes sense to also allow more flexibility for the date string format in input.

What does the proposed API look like?

<template>
  <a-date-picker
    v-model="value"
    :format="customFormat"
  >

  </a-date-picker>
</template>

<script>
  export default {
    data() {
      return {
        value: null,
      }
    },
    methods: {
      customFormat(value) {
        return getLunarDateString(value); // custom implementation to get lunar calendar date
      }
    }
  };
</script>

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