Element: [Bug Report] el-date-picker[type=week]: `value-format` invalidation of `format`

Created on 12 Dec 2017  ·  16Comments  ·  Source: ElemeFE/element

Element UI version

2.0.7

OS/Browsers version

windows10 chrome63.0.3239.84(正式版本) (64 位)

Vue version

2.5.2

Reproduction Link

https://jsfiddle.net/bowencool/ndkdwyka/1/

Steps to reproduce

见链接

What is Expected?

正常展示就行

What is actually happening?

不能正常展示数据

date-picker next major candidate discussion

Most helpful comment

why this issue not solved after one year??

All 16 comments

Translation of this issue:

Element UI version

2.0.7

OS/Browsers version

Windows10 chrome63.0.3239.84 (official version) (64 bit)

Vue version

2.5.2

Reproduction Link

https://jsfiddle.net/bowencool/ndkdwyka/1/

Steps to reproduce

See links

What is Expected?

Normal display is all right

What is actually happening?

No normal display of data

@wacky6 Hi, could you take a look at this? Thanks.

Fecha does not support parsing / formatting of week. I guess element need to hack it somehow? Modify week's parser might solve the problem.

I might consider removing week in value-format, since it can not accurately indicate a time point (depends on the interpretation of start-of-week, etc).

I might consider removing week in value-format, since it can not accurately indicate a time point (depends on the interpretation of start-of-week, etc).

IMHO it is a valid value format. You are using ISO8601 week numbers and they are always starting with Monday.

https://github.com/ElemeFE/element/blob/af46f968ab8f56ddb87932eab35993782c4d5b2f/packages/date-picker/src/util/index.js#L97-L107


Anyways, the error (vue.js:1719 TypeError: e.getTime is not a function) also happens when you do not use WW in the value-format. E.g. in this fiddle I changed the value-format to yyyy-MM-dd and the error happens, too.

If you have a el-date-picker[type=week] and also set the value-format this error occurs. Looks like el-date-picker[type=week] cannot handle anything besides a JavaScript Date object as value.

This line
https://github.com/ElemeFE/element/blob/aaf7a87848d33d3f07310f2865e4d3d14019c6f0/packages/date-picker/src/picker.vue#L167
should probably be

      let week = getWeekNumber(isDateObject(value) ? value : parseDate(value, format));

Interesting.

Can you make a PR for it?
I recommend integrate week format into our custom fecha (/src/utils/date.js)? So date-picker can treat week number as normal dates. (Thus removing custom week picker logic)

@Leopoldthecoder
What's the reasoning of current implementation? Will this be a breaking change?

Make fecha support WW/W format, so element can drop custom week picker logic, see TYPE_VALUE_RESOLVER_MAP's week

Any updates on this issue ?

when i set {type="week",value-format="yyyy-W"} ,will meet the same bug!
" Error in render: "TypeError: src.getTime is not a function""
please help

Right now, W is not supported in value-format. Use MM/dd instead.
The definition of W / WW format needs consensus. ISO-8601 week date may be considered in the future.

呜呜呜,终于知道为什么了,花了我半天时间,这磨人的week

why this issue not solved after one year??

el-date-picker 像下面这样设置时,输入框的格式一直不正确

<el-date-picker
v-model="value1"
      type="week"
      format="yyyy 第 W 周"
      value-format="yyyy-W"
      placeholder="选择周">
</el-date-picker>

预览链接

same problem here

Hi, can someone add this feature?
image
value-format still not support WW...

I use the computed attribute to parse week. But it's not very convinient.
computed: { week() { return moment(this.date.W).format('YYYY [wk]WW'); } }

Still no update? :(

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chao-hua picture chao-hua  ·  3Comments

mochenxm picture mochenxm  ·  3Comments

fscardua picture fscardua  ·  3Comments

gengxuelei picture gengxuelei  ·  3Comments

akaylh picture akaylh  ·  3Comments