Mind Expression Docs
English
  • Mind Expression Docs
  • Why Mind Expression
  • Quickstarts
    • Create Scope
    • Add Subject
    • Test
    • Audit
  • Concepts
    • Scopes
    • Subjects
    • Components
    • Sandbox
    • Conversation history
    • Webhooks and escalation
    • Knowledge
    • Live Chat
    • Target Messages
    • Analytics
  • How-to Guides
    • Set up webhooks and escalation
    • Manage global keys
    • Customize messages
    • Educate AI
      • Manage ontologies
      • Recognition Check
      • Semantic Relations
      • Manage entities
    • Steps
    • Components
      • Normal Components
        • Conditions
        • Selection Classes
        • Parameter Bundles
      • Response Components
        • Component Actions
    • Build Q&A Subjects
      • Case 1. Online Payment
      • Case 2. Data Plans
    • Build Info Search Subjects
      • Case 1. Data Usage
      • Case 2. Payment History
    • Build Query Freestyle Subjects
      • Case 1. Data Purchase
      • Case 2. Change Mobile Plan
    • Intelligent Process
      • Introduction to Mindscript
      • Mindscript with Mind Expression
      • Frequently Asked Question
      • Package: Collections and Sequenceable
      • Package: Collections Unordered
      • Package: Collections-Strings
      • Package: Engine-Conversation
      • Package: Kernel-HTTP
      • Package: Kernel-Methods
      • Package: Kernel-Numbers
      • Package: Kernel-Dates
      • Package: Kernel-Objects
      • Package: Kernel Exceptions
      • Package: Cryptography
    • Test and debug
    • Integration
      • Mind Expression API
      • Chat Widget
      • LINE
      • Facebook Messenger
      • Viber
      • Instagram
      • Discord
      • WhatsApp
      • Google Sheet
        • Google Sheet Webhook
      • Google Calendar
        • Google Calendar Webhook
        • Google Calendar: Use Cases
    • Audit AI Activities
    • Live Chat
    • Target Messages
    • Back up, import and restore Scopes
  • Reference
    • Glossary
    • API Docs
Powered by GitBook
On this page
  • Class: Date
  • Introduction
  • Class Method

Was this helpful?

  1. How-to Guides
  2. Intelligent Process

Package: Kernel-Dates

Class: Date

Introduction

Environment: container

A Date is an object which holds a specific point in time, from year to seconds.

Currently, there are hard-coded strings for days of the week (Monday - Sunday) as well as months in a year (January - December), and also their abbreviations.

Both days of week and months in year are indexed starting with 1 (Monday and January).

Most of the available functions use the Date class instead of a Date instance.

For example:

dv := Date daysInYear: 2024. "dv = 366"

dv := Date daysInMonth: 'February' forYear: 2020. "dv = 29"
dv := Date daysInMonth: 'October' forYear: 2022. "dv = 31"

ds := ':'.
dv := { 3. 6. 9 } do: [ :each | ds := ds + (Date shortNameOfMonth: each) + ':' ].
ds = ':Mar:Jun:Sep:'. "true"

Class Method

Category: accessing

  • abbreviationOfDay: - Answer the abbreviated name of the day of week corresponding to the given index (1=Mon, 7=Sun based).

    For example:

    dv := Date abbreviationOfDay: 2. "dv = 'Tue'"
  • dayOfWeek: - Answer the index of the day of week corresponding to the given name (1=Monday, 7=Sunday based).

    For example:

    dv := Date dayOfWeek: 'Monday'. "dv = 1"
  • daysInMonth:forYear: - Answer the number of days in the given (named) month for the given year.

    For example:

    dv := Date daysInMonth: 'February' forYear: 2024. "dv = 29"
    dv := Date daysInMonth: 'December' forYear: 2024. "dv = 31"
  • daysInYear: - Answer the number of days in the given year.

    For example:

    dv := Date daysInYear: 2020. "dv = 366"
    dv := Date daysInYear: 2021. "dv = 365"
  • indexOfMonth: - Answer the index of the month corresponding to the given name (1=January based).

    For example:

    dv := Date indexOfMonth: 'February'. "dv = 2"
  • nameOfDay: - Answer the name of the day of week corresponding to the given index (1=Monday, 7=Sunday based).

    For example:

    dv := Date nameOfDay: 4. "dv = 'Thursday'"
  • nameOfMonth: - Answer the name of the month corresponding to the given index (1=January based).

    For example:

    dv := Date nameOfMonth: 4. "dv = 'April'"
  • shortNameOfMonth: - Answer the name of the month corresponding to the given index (1=January based).

    For example:

    dv := Date shortNameOfMonth: 4. "dv = 'Apr'"

Category: instance creation

  • year:day:hour:minute:second: - Answer a Date denoting the d-th day of the given year.

    For example:

    dv := Date year: 2023 day: 32 hour: 1 minute: 0 second: 0.
    "dv = @2023-02-01T01:00:00.000000Z"
  • year:month:day:hour:minute:second: - Answer a Date denoting the d-th day of the given (as a number) month and year.

    For example:

    dv := Date year: 2023 month: 2 day: 1 hour: 1 minute: 0 second: 0.
    "dv = @2023-02-01T01:00:00.000000Z"
PreviousPackage: Kernel-NumbersNextPackage: Kernel-Objects

Last updated 10 months ago

Was this helpful?