Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.1.0 - 日本語


weekday

Day's index and name in its week for given dates

Syntax

[I, Names] = weekday()
[I, Names] = weekday(N)
[I, Names] = weekday(YMD)
[I, Names] = weekday(Y, M, D)
[I, Names] = weekday(dateStrings)
[I, Names] = weekday(.., "long")
[I, Names] = weekday(.., la_NG)

Arguments

N

Array of decimal date numbers as returned by datenum(..).

YMD

Matrix of decimal integers with n rows and 3 columns. Each row defines a date: Year numbers are in column YMD(:,1). Month indices in [1,12] are in column YMD(:,2). Day indices in [1,31] are in column YMD(:,3).

Y, M, D

3 element-wise arrays of decimal integers with the same sizes. The date #i is defined by D(i)/M(i)/Y(i).

dateStrings

Array of strings specifying dates according to 5 possible formats described here-below. In the array, all the dates must follow the same format:

  • "YYYY-MM-DD" : DD < 10 or/and MM < 10 must have a leading zero. Example: "2017-09-07".
  • "YYYY-MM-DD HH:MN:SS.ss" or "YYYY-MM-DD whatever you want" : same as above. Only the part before the first space is considered.
  • "D/M/Y" : Days D < 10 or/and Months M < 10 may or not have a leading zero. Example: "7/09/2017".
  • "enD/M/Y" : Same as above, with the prefix "en" (for "english") and M/D instead of D/M. Example: "en7/24/2017".
  • "D-Mmm-YYYY" where Mmm is the short name of the Month in english: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec. Days D < 10 may or not have a leading zero.

"long"

Optional keyword to get days names in long full form: "Wednesday" instead of "Wed", etc. Can be used anywhere after the Days input argument(s).

la_NG

Optional keyword = unique string specifying the language in which days names are requested, in the standard format like "en_US", "fr_FR", etc. Can be used anywhere after the Days input argument(s).

I

Array of decimal integers in [1,7], having the sizes of N, YMD(:,1), Y, M and D, or dateStrings: 1 is for Sunday, 2 for Monday, .., 7 for Saturday.

Names

Array of text words having I sizes: Names of days in their weeks, for the given dates. Names are returned in short form like "Wed" standing for "Wednesday", unless the "long" option is used.

Description

For each given dates, or by default for today, weekday computes and returns the integer index of the day in its week, from 1 to 7. The abbreviated or full name of the day may also be returned, in the Scilab session language. If a language code is provided and targets a language supported in Scilab, the day name is translated into the language before being returned.

Langishortlong.......Langishortlong
en_US1SunSundaypt_BR1DomDomingo
en_US2MonMondaypt_BR2SegSegunda-feira
en_US3TueTuesdaypt_BR3TerTerça-feira
en_US4WedWednesdaypt_BR4QuaQuarta-feira
en_US5ThuThursdaypt_BR5QuiQuinta-feira
en_US6FriFridaypt_BR6SexSexta-feira
en_US7SatSaturdaypt_BR7SábSábado
fr_FR1Dim.Dimancheru_RU1ВскВоскресенье
fr_FR2Lun.Lundiru_RU2ПндПонедельник
fr_FR3Mar.Mardiru_RU3ВтрВторник
fr_FR4Mer.Mercrediru_RU4СрдСреда
fr_FR5Jeu.Jeudiru_RU5ЧтвЧетверг
fr_FR6Ven.Vendrediru_RU6ПтнПятница
fr_FR7Sam.Samediru_RU7СбтСуббота
ja_JP1日曜日zh_CN1星期日星期日
ja_JP2月曜日zh_CN2星期一星期一
ja_JP3火曜日zh_CN3星期二星期二
ja_JP4水曜日zh_CN4星期三星期三
ja_JP5木曜日zh_CN5星期四星期四
ja_JP6金曜日zh_CN6星期五星期五
ja_JP7土曜日zh_CN7星期六星期六

Examples

// Today
[i, n] = weekday()
[i, n] = weekday("long"); n
[i, n] = weekday("long","ru_RU"); n

// Explicit input dates
[I, N] = weekday(     ["01/1/1970" "11/09/2001" "26/12/2004"])
[I, N] = weekday("en"+["1/01/1970" "09/11/2001" "12/26/2004"])
[I, N] = weekday(["1/1/1970" "11/9/2001" "26/12/2004"], "long"); N
[I, N] = weekday(["1970-01-01" "2001-09-11" "2004-12-26"], "long"); N
[I, N] = weekday(["1970-01-01 00:00:00" "2001-09-11 08:14:00" "2004-12-26 00:58:53"], "long"); N
[I, N] = weekday(["1-Jan-1970" "11-Sep-2001" "26-Dec-2004"], "long"); N
[I, N] = weekday(["1970-01-01" "en12/26/2004"]);   // => error: all dates must have the same format
[I, N] = weekday([1970 1 1 ; 2001 9 11 ; 2004 12 26], "long"); N
[I, N] = weekday([1970 2001 2004], [1 9 12], [1 11 26], "long"); N
D = datenum([1970 1 1 ; 2001 9 11 ; 2004 12 26])
[I, N] = weekday(D, "long"); N

// Language option
[I, N] = weekday(["1/1/1970" "11/9/2001" "26/12/2004"], "zh_CN"); N
[I, N] = weekday(["1/1/1970" "11/9/2001" "26/12/2004"], "fr_FR", "long"); N

See also

  • eomday — 月の最後の日を返す
  • datenum — シリアル日付番号に変換する
  • datevec — 日付の要素

History

バージョン記述
6.1.0
  • New syntaxes added: weekday(), weekday(YMD), weekday(Y, M, D), weekday(dateStrings).
  • Language option added.
  • Algorithm now based on datenum() (5 formats).
Report an issue
<< toc Time and Date Output functions >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon May 22 12:43:11 CEST 2023