Explore all Calendar open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Calendar

fullcalendar

tui.calendar

v1.15.3

react-native-calendars

1.1282.0

Pikaday

Version 1.8.2

react-big-calendar

v0.40.1

Popular Libraries in Calendar

fullcalendar

by fullcalendar doticontypescriptdoticon

star image 14868 doticonMIT

Full-sized drag & drop event calendar

tui.calendar

by nhn doticonjavascriptdoticon

star image 9830 doticonMIT

🍞📅A JavaScript calendar that has everything you need.

CalendarView

by huanghaibin-dev doticonjavadoticon

star image 7808 doticonApache-2.0

Android上一个优雅、万能自定义UI、仿iOS、支持垂直、水平方向切换、支持周视图、自定义周起始、性能高效的日历控件,支持热插拔实现的UI定制!支持标记、自定义颜色、农历、自定义月视图各种显示模式等。Canvas绘制,速度快、占用内存低,你真的想不到日历居然还可以如此优雅!An elegant, highly customized and high-performance Calendar Widget on Android.

react-native-calendars

by wix doticontypescriptdoticon

star image 7635 doticonMIT

React Native Calendar Components 🗓️ 📆

Pikaday

by Pikaday doticonjavascriptdoticon

star image 7485 doticonNOASSERTION

A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS

JTAppleCalendar

by patchthecode doticonswiftdoticon

star image 7165 doticonMIT

The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable

gitfiti

by gelstudios doticonpythondoticon

star image 6366 doticonMIT

abusing github commit history for the lulz

react-big-calendar

by jquense doticonjavascriptdoticon

star image 5627 doticonMIT

gcal/outlook like calendar component

CVCalendar

by CVCalendar doticonswiftdoticon

star image 3415 doticonMIT

A custom visual calendar for iOS 8+ written in Swift (>= 4.0).

Trending New libraries in Calendar

MeetingBar

by leits doticonswiftdoticon

star image 2940 doticonApache-2.0

🇺🇦 Your next meeting always before your eyes in the macOS menu bar

bloom

by skerkour doticonrustdoticon

star image 1334 doticonNOASSERTION

The simplest way to de-Google your life and business: Inbox, Calendar, Files, Contacts & much more

nettu-scheduler

by fmeringdal doticonrustdoticon

star image 447 doticonMIT

A self-hosted calendar and scheduler server.

calendarize

by lukeed doticonjavascriptdoticon

star image 429 doticonMIT

A tiny (202B) utility to generate calendar views.

livewire-calendar

by asantibanez doticonphpdoticon

star image 273 doticonMIT

Laravel Livewire component to show Events in a good looking monthly calendar

atomic-calendar-revive

by totaldebug doticontypescriptdoticon

star image 187 doticonMIT

Custom calendar card for Home Assistant with Lovelace

lecture-python.notebooks

by QuantEcon doticonjupyter notebookdoticon

star image 173 doticon

Notebooks for https://python.quantecon.org

calendar

by aeon-php doticonphpdoticon

star image 157 doticonMIT

📅 PHP Date & Time library that solves common problems in object oriented, immutable way.

react-calendar

by veccu doticontypescriptdoticon

star image 120 doticonMIT

:calendar: React Hooks for building extensible calendar user interface (a.k.a Headless Calendar)

Top Authors in Calendar

1

6tail

8 Libraries

star icon859

2

KDE

6 Libraries

star icon28

3

spatie

5 Libraries

star icon1759

4

Abror777

5 Libraries

star icon10

5

fullcalendar

5 Libraries

star icon17504

6

BaseMax

5 Libraries

star icon17

7

SCR-IR

5 Libraries

star icon43

8

jalaali

5 Libraries

star icon1081

9

kollavarsham

5 Libraries

star icon27

10

omid

4 Libraries

star icon347

1

8 Libraries

star icon859

2

6 Libraries

star icon28

3

5 Libraries

star icon1759

4

5 Libraries

star icon10

5

5 Libraries

star icon17504

6

5 Libraries

star icon17

7

5 Libraries

star icon43

8

5 Libraries

star icon1081

9

5 Libraries

star icon27

10

4 Libraries

star icon347

Trending Kits in Calendar

Here are some famous Django Calendar Libraries. Some of the use cases of Django Calendar Libraries include Event Management, Scheduling Appointments, Time Tracking, Reminders and Notifications, and Resource Allocation.


Django calendar libraries are a type of library that provide developers with a set of tools for integrating calendar-based features into their Django projects. These libraries allow developers to easily add calendar-based features, such as event scheduling and appointment booking, to their web applications.


Let us look at the libraries in detail below.

django-scheduler

  • Ability to embed calendar views in other web pages.
  • Automatically generated calendar URLs.
  • Support for recurrence rules and exceptions.

django-schedule

  • Allows users to customize the views and display options of their calendar.
  • Includes event management features.
  • Allows users to control who can view or edit their calendar and events.

django-calendarium

  • Provides easy integration with other Django applications.
  • Offers an optional calendar widget for displaying an event list.
  • Provides out-of-the-box support for iCalendar.

django-eventtools

  • Supports both recurring and single-time events.
  • Supports multiple time zones.
  • Allows you to easily add and manage events from the admin panel.

django-cal

  • Flexible event and calendar models which allow you to customize the data stored in your calendar.
  • Template tags for easy integration with other Django apps.
  • Built-in RSS feed to easily share your calendar with others.

django-ical

  • Supports both the iCalendar and RFC5545 standards.
  • Allows the users to easily import and export calendar data from a variety of sources.
  • Provides a powerful set of tools such as filtering, sorting, and searching.

django-happenings

  • Provides templste tags that allow for quick and easy integration of calendar views.
  • Designed to integrate with other Django apps.
  • Comes with comprehensive documentation that covers installation, configuration, and usage.


django-event-calendar

  • Supports different types of events such as lectures, meetings, and workshops.
  • Allows multiple users to add, edit, and delete events from a shared calendar.
  • Allows users to customize the fields associated with an event, such as location, time, and description.

django-calendar

  • Responsive design and cross-browser compatibility.
  • Multi-calendar support.
  • Has a user-friendly interface that makes it easy for users to navigate and interact.

django-diary 

  • Features a drag-and-drop interface to quickly and easily create and manage events. 
  • Supports multiple calendar views, such as monthly, weekly, and agenda. 
  • Supports multiple languages, allowing users to create events in their native language. 


Creating a calendar widget involves building a component. It displays a monthly calendar to navigate between months and highlight selected dates.


Many developers could face it tedious to work with dates and calendar, which can be simplified by using libraries like react-calendar. It has options to pick dates, months, years, or even decades and also has an option to select range of dates. In this solution kit, I am sharing the code snippet and library that I use.


PS: Preview of the output that you will get on running this code from your IDE

Code

In this solution we use the Calendar of the react-calendar library.

  1. Copy the code using the "Copy" button above, and paste it in a react application in your IDE.
  2. Run the application in your server to see the calendar in your page.


You can also add styling to the calendar by adding this piece of code

import 'react-calendar/dist/Calendar.css';


I hope you found this useful. I have added the link to dependent libraries in the following sections.


I found this code snippet by searching for "react calendar" in kandi. You can try any such use case!

Dependent Libraries

Install the react-calendar using above library either by visiting GitHub or npm


You can search for any dependent library on kandi like react-calendar.

Environment Tested

I tested this solution in the following versions. Be mindful of changes when working with other versions.

  1. The solution is created in react v18.2.0 and react-calendar v4.0.0
  2. The solution is tested on chrome browser

Support

  1. For any support on kandi solution kits, please use the chat
  2. For further learning resources, visit the Open Weaver Community learning page.

The React-Calendar libraries provide the functionality to help manipulate and manage dates & times. It allows end-users to pick a day, month, or year. 


For easily internationalized and mobile-friendly, consider using the library React-dates. Consider using libraries like React-modern-calendar-date picker and react date picker. We can also consider libraries like React-calendar-timeline for a beautiful and customizable. 


React date picker is a comprehensive date picker of React components. To handle large amounts of data without performance degradation, consider using React-Gantt-schedule-timeline-calendar. To perform a basic calendar implementation, first, we must install the React Calendar library. Then import Calendar into our React application as import react-calendar. To create a simple calendar, first, create React App and write a function:

createCalendar(elem, year, month).


The interactive Calendar allows us to jot events into their happening date. It will ensure that we remember everything. With this basic structure ready, our initial Calendar will look similar. A promise resolves to the Calendar object, the user's default calendar. For example, the React Calendar library can use for booking apps for reserving. 


We can synchronize events between our React Event Calendar and Google or Outlook Calendar. We can do it via the Google Calendar API or Microsoft Outlook's object library. We must pass the selectRange prop to our <Calendar /> component to enable a date range feature. A promise resolves to the Calendar object, the user's default calendar. Calendar value that we can select initially. Class names will apply to a given calendar item. The items can be a day-on-month view or a month-on-year view. The syntax for calendar onChange is Calendar onChange = { onChange } value = {value}. 


We can render the attribute of a label on the calendar navigation bar. The calendar view helps everything from single to many-week views to month grids. It can be with different ways to render events. We will make changes to the appearance using the configuration object and CSS. Customize the week's first day, which defaults to Sunday. We can do it as per the default locale and the setting, which will make weekends appear from Friday to Saturday. However, we can render days from the previous or next month. We can do this if the month doesn't start on the week's first day or doesn't end on the last day, respectively. Clicking on the text indicator in a month. It is because the timeline views will open an event container listing. It will have all the hidden event and appointment details of the day. The Fast Navigation Bar of the KendoReact Calendar offers a shortcut. It helps to navigate through years and months quickly. It will do it without the context of the main calendar interface of selecting a particular day. 


React Calendar uses modern web technologies. But this comes at the cost of supporting only modern browsers. Lastly, you can also customize the React Calendar using different props: 

  • defaultValue (Specify a default chosen value), 
  • defaultView (allows you to customize the Calendar's date view),
  • maxDate & minDate (prevent the user from choosing a date after a specific day. 


We have identified the best libraries based on popularity, flexibility, and coverage. Let's look at each library in detail. 

React-dates: 

  • It is a datepicker library. 
  • It is a lightweight library with many features. We can import the custom component and set up two props. 
  • It is an easily internationalized, accessible, mobile-friendly datepicker library for the web. 
  • It is an advanced daterangepicker component with highly customizable options. 

React-calendar-timeline: 

  • It is a modern and responsive React timeline component. 
  • It displays the timeline scheduler views for many resources. 
  • Timeline views support an intuitive drag-and-drop feature and a resize action. 
  • Horizontally scrollable view with many resources. It supports day, week, and month with built-in templating. 

React-Gantt-schedule-timeline-calendar: 

  • It allows us to load amounts of data without performance degradation. 
  • It can change almost everything from DOM tree to logic. 
  • Fast event with a large dataset. 
  • We can easily add third-party libraries. 

React-date-picker: 

  • A reusable Datepicker component for React. 
  • It is a helpful and abundant component. It displays dates using the calendar dialog format. 
  • It will support virtually any language. 
  • Can pick days, months, years, or even decades. 

React-infinite-calendar: 

  • It is flexible: minimum, maximum date, disabled dates, disabled days, etc. 
  • Easily customizable, and it will theme to our heart's content. 
  • Year selection for rapid jumping from year to year. 
  • Mobile-friendly, silky-smooth scrolling on mobile. 

React-modern-calendar-datepicker: 

  • A modern and customizable date picker for React. 
  • Easily switch between dropdown and calendar view or single and range selection. 
  • It enhances the Calendar with marked days or labels. 
  • Capabilities like built-in validation, minimum and maximum values, and disabled dates. We can support it with the scroller and Calendar. 

React-calendar: 

  • Light and fast - surely, we could use moment.js and call it a day, but the modern web allows us to do much more with much less. 
  • Customizable - there are tons of options to choose from to make React Calendar truly ours. 
  • Supports any language - their languages support us no matter where we are from. 
  • Open - the only way to make progress is to share. We have always relied on dozens of libraries created by other developers. 

FAQ: 

1. What is the default React-Calendar styling? 

The default React-calendar styling is by overriding Calendar.css. We can copy the default calendar CSS in a local file from node modules/react-calendar. Then we can import the same file into App.js, our React application, instead of the default calendar CSS. 


2. How do I create a React Calendar component for my website? 

  • Create a simple calendar component. 
  • Create a table that uses a calendar. 
  • Change the month and year. 
  • Get the date value from React calendar onclick. 


3. What are the advantages of React date picker library instead of coding it from scratch? 

  • Provides various options and features. 
  • It allows a smoother input experience. 
  • It allows us to set or select the date with only a mouse and dismisses the necessity of writing down the date. 


4. Can I use Create React App to build a calendar implementation from scratch? 

  1. Get the Google API key. 
  2. Restrict the API key. 
  3. Make our calendar public. 
  4. Get the calendar ID, and open google calendar settings.
  5. Choose the Calendar we want to integrate and copy it from the integrate calendar section. 
  6. Finally, set up the scheduler. 


5. How can I allow users to select their default date range when they open the calendar page? 

On the calendar page, the Date picker provides an option to choose a date value within a specified range. We can do it using the min and max properties, and always the min value has to be less than the max value. 

Trending Discussions on Calendar

Android Studio - Unable to capture video from Camera

Problems when writing parquet with timestamps prior to 1900 in AWS Glue 3.0

Discrepancy in Javascript Intl.DateTimeFormat() Outputs for the Islamic (Hijri) Calendar between 'islamic' and 'ar-SA'

Class 'action' is not abstract and does not implement abstract member public abstract val actionId: Int defined in androidx.navigation.NavDirections

Flexible layout: Is this one possible?

calendar Ant Design: how to show event only in specific day in month using React JS

Is there a way to disable the month/viewmode button in bootstrap-datetimepicker?

Ethiopian calendar in Android

Most reliable hook for setting next renewal payment date after order

iOS 14 widget works locally, but fails via TestFlight

QUESTION

Android Studio - Unable to capture video from Camera

Asked 2022-Mar-23 at 22:41

I am trying to capture video via Gallery or via Camera. I am able to successfully fetch the video from Gallery. However when I try to record the video from camera it loses the track and I am unable to fetch the path. It does save the video on path. The log give following error/warning. Why is is losing track of the video recorder? Where am I going wrong?

12022-03-15 07:32:08.683 14318-14318/com.example.locationfetcher_v2 W/MirrorManager: this model don't Support
22022-03-15 07:32:13.864 14318-14318/com.example.locationfetcher_v2 D/DecorView: createDecorCaptionView windowingMode:1 mWindowMode 1 isFullscreen: true
32022-03-15 07:32:14.875 14318-14318/com.example.locationfetcher_v2 I/Timeline: Timeline: Activity_launch_request time:174742145
42022-03-15 07:32:14.912 14318-14395/com.example.locationfetcher_v2 D/OpenGLRenderer: endAllActiveAnimators on 0xb400007e4ade6e00 (AlertController$RecycleListView) with handle 0xb400007e52639220
52022-03-15 07:32:20.913 14318-14339/com.example.locationfetcher_v2 W/System: A resource failed to call close
6

Here is my code:

12022-03-15 07:32:08.683 14318-14318/com.example.locationfetcher_v2 W/MirrorManager: this model don't Support
22022-03-15 07:32:13.864 14318-14318/com.example.locationfetcher_v2 D/DecorView: createDecorCaptionView windowingMode:1 mWindowMode 1 isFullscreen: true
32022-03-15 07:32:14.875 14318-14318/com.example.locationfetcher_v2 I/Timeline: Timeline: Activity_launch_request time:174742145
42022-03-15 07:32:14.912 14318-14395/com.example.locationfetcher_v2 D/OpenGLRenderer: endAllActiveAnimators on 0xb400007e4ade6e00 (AlertController$RecycleListView) with handle 0xb400007e52639220
52022-03-15 07:32:20.913 14318-14339/com.example.locationfetcher_v2 W/System: A resource failed to call close
6public void showPictureDialog(View view){
7        AlertDialog.Builder pictureDialog = new AlertDialog.Builder(this);
8        pictureDialog.setTitle(&quot;Select Action&quot;);
9        String[] pictureDialogItems = {
10                &quot;Select video from gallery&quot;,
11                &quot;Record video from camera&quot; };
12        pictureDialog.setItems(pictureDialogItems,
13                new DialogInterface.OnClickListener() {
14                    @Override
15                    public void onClick(DialogInterface dialog, int which) {
16                        switch (which) {
17                            case 0:
18                                chooseVideoFromGallery();
19                                break;
20                            case 1:
21                                takeVideoFromCamera();
22                                break;
23                        }
24                    }
25                });
26        pictureDialog.show();
27    }
28
29
30    public void chooseVideoFromGallery() {
31        Intent galleryIntent = new Intent(Intent.ACTION_PICK,
32                android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
33
34        startActivityForResult(galleryIntent, PICK_VIDEO_GALLERY);
35    }
36
37    private void takeVideoFromCamera() {
38        Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
39        intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
40        startActivity(intent);
41    }
42
43    public String getPath(Uri uri) {
44        String[] projection = { MediaStore.Video.Media.DATA };
45        Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
46        if (cursor != null) {
47            // HERE YOU WILL GET A NULLPOINTER IF CURSOR IS NULL
48            // THIS CAN BE, IF YOU USED OI FILE MANAGER FOR PICKING THE MEDIA
49            int column_index = cursor
50                    .getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
51            cursor.moveToFirst();
52            return cursor.getString(column_index);
53        } else
54            return null;
55    }
56
57    private void saveVideoToInternalStorage (String filePath) {
58
59        File newfile;
60
61        try {
62
63            File currentFile = new File(filePath);
64//            show_notification(&quot;New File Video:&quot; + Environment.getExternalStorageDirectory());
65            File wallpaperDirectory = new File(Environment.getExternalStorageDirectory() + VIDEO_DIRECTORY);
66            newfile = new File(wallpaperDirectory, Calendar.getInstance().getTimeInMillis() + &quot;.mp4&quot;);
67
68            if (!wallpaperDirectory.exists()) {
69                wallpaperDirectory.mkdirs();
70            }
71
72            if(currentFile.exists()){
73
74                InputStream in = new FileInputStream(currentFile);
75                OutputStream out = new FileOutputStream(newfile);
76
77                // Copy the bits from instream to outstream
78                byte[] buf = new byte[1024];
79                int len;
80
81                while ((len = in.read(buf)) &gt; 0) {
82                    out.write(buf, 0, len);
83                }
84                in.close();
85                out.close();
86                show_notification(&quot;Video file saved successfully.&quot;);
87            }else{
88                show_notification(&quot;Video saving failed. Source file missing.&quot;);
89            }
90        } catch (Exception e) {
91            show_notification(e.toString());
92            e.printStackTrace();
93        }
94
95@RequiresApi(api = Build.VERSION_CODES.Q)
96    @Override
97    public void onActivityResult(int requestCode, int resultCode, Intent data) {
98        super.onActivityResult(requestCode, resultCode, data);
99        inputStreamImg = null;
100        if (requestCode == PICK_VIDEO_GALLERY){
101            if (data != null) {
102                Uri contentURI = data.getData();
103
104                String selectedVideoPath = getPath(contentURI);
105                Log.d(&quot;path&quot;,selectedVideoPath);
106//                show_notification(&quot;Saving...&quot;);
107                saveVideoToInternalStorage(selectedVideoPath);
108                vidView.setVideoURI(contentURI);
109                vidView.requestFocus();
110                vidView.start();
111                videoPath = selectedVideoPath;
112                show_notification(&quot;video Gallery - &quot; + videoPath);
113            } else if (requestCode == PICK_VIDEO_CAMERA) {
114                Uri contentURI = data.getData();
115                show_notification(contentURI.getPath());
116                String recordedVideoPath = getPath(contentURI);
117                show_notification(recordedVideoPath);
118                saveVideoToInternalStorage(recordedVideoPath);
119
120                videoPath = recordedVideoPath;
121
122                vidView.setVideoURI(contentURI);
123                vidView.requestFocus();
124                vidView.start();
125                show_notification(&quot;video Camera - &quot; + videoPath);
126            }
127        }
128    }
129

ANSWER

Answered 2022-Mar-22 at 18:12

I don't know if it will help but maybe you should do startActivityForResult or ActivtyResultLauncher. I would comment that if I had enough reputation.

Source https://stackoverflow.com/questions/71476425

QUESTION

Problems when writing parquet with timestamps prior to 1900 in AWS Glue 3.0

Asked 2022-Feb-10 at 13:45

When switching from Glue 2.0 to 3.0, which means also switching from Spark 2.4 to 3.1.1, my jobs start to fail when processing timestamps prior to 1900 with this error:

1An error occurred while calling z:org.apache.spark.api.python.PythonRDD.runJob.
2You may get a different result due to the upgrading of Spark 3.0: reading dates before 1582-10-15 or timestamps before 1900-01-01T00:00:00Z from Parquet INT96 files can be ambiguous, 
3as the files may be written by Spark 2.x or legacy versions of Hive, which uses a legacy hybrid calendar that is different from Spark 3.0+s Proleptic Gregorian calendar.
4See more details in SPARK-31404.
5You can set spark.sql.legacy.parquet.int96RebaseModeInRead to 'LEGACY' to rebase the datetime values w.r.t. the calendar difference during reading. 
6Or set spark.sql.legacy.parquet.int96RebaseModeInRead to 'CORRECTED' to read the datetime values as it is.
7

I tried everything to set the int96RebaseModeInRead config in Glue, even contacted the Support, but it seems that currently Glue is overwriting that flag and you can not set it yourself.

If anyone knows a workaround, that would be great. Otherwise I will continue with Glue 2.0. and wait for the Glue dev team to fix this.

ANSWER

Answered 2022-Feb-10 at 13:45

I made it work by setting --conf to spark.sql.legacy.parquet.int96RebaseModeInRead=CORRECTED --conf spark.sql.legacy.parquet.int96RebaseModeInWrite=CORRECTED --conf spark.sql.legacy.parquet.datetimeRebaseModeInRead=CORRECTED --conf spark.sql.legacy.parquet.datetimeRebaseModeInWrite=CORRECTED.

This is a workaround though and Glue Dev team is working on a fix, although there is no ETA.

Also this is still very buggy. You can not call .show() on a DynamicFrame for example, you need to call it on a DataFrame. Also all my jobs failed where I call data_frame.rdd.isEmpty(), don't ask me why.

Update 24.11.2021: I reached out to the Glue Dev Team and they told me that this is the intended way of fixing it. There is a workaround that can be done inside of the script though:

1An error occurred while calling z:org.apache.spark.api.python.PythonRDD.runJob.
2You may get a different result due to the upgrading of Spark 3.0: reading dates before 1582-10-15 or timestamps before 1900-01-01T00:00:00Z from Parquet INT96 files can be ambiguous, 
3as the files may be written by Spark 2.x or legacy versions of Hive, which uses a legacy hybrid calendar that is different from Spark 3.0+s Proleptic Gregorian calendar.
4See more details in SPARK-31404.
5You can set spark.sql.legacy.parquet.int96RebaseModeInRead to 'LEGACY' to rebase the datetime values w.r.t. the calendar difference during reading. 
6Or set spark.sql.legacy.parquet.int96RebaseModeInRead to 'CORRECTED' to read the datetime values as it is.
7sc = SparkContext()
8# Get current sparkconf which is set by glue
9conf = sc.getConf()
10# add additional spark configurations
11conf.set(&quot;spark.sql.legacy.parquet.int96RebaseModeInRead&quot;, &quot;CORRECTED&quot;)
12conf.set(&quot;spark.sql.legacy.parquet.int96RebaseModeInWrite&quot;, &quot;CORRECTED&quot;)
13conf.set(&quot;spark.sql.legacy.parquet.datetimeRebaseModeInRead&quot;, &quot;CORRECTED&quot;)
14conf.set(&quot;spark.sql.legacy.parquet.datetimeRebaseModeInWrite&quot;, &quot;CORRECTED&quot;)
15# Restart spark context
16sc.stop()
17sc = SparkContext.getOrCreate(conf=conf)
18# create glue context with the restarted sc
19glueContext = GlueContext(sc)
20

Source https://stackoverflow.com/questions/68891312

QUESTION

Discrepancy in Javascript Intl.DateTimeFormat() Outputs for the Islamic (Hijri) Calendar between 'islamic' and 'ar-SA'

Asked 2022-Feb-06 at 13:50

The 3rd March 2022 is the end of this Hijri Month (month of Rajab for this year 1443 AH); i.e. 30 Rajab 1443 AH.

The month of Rajab for the year 1443 AH is 30 days in accordance with the Islamic (Hijri) Calendar in accordance with all websites, applications, MS Office, and Windows calendars.

When using the javascript Intl.DateTimeFormat() to display the Islamic (Hijri) date for the 3 March 2022 using the islamic calendar option, it will give the Islamic Hijri Date of (1 Shaʻban 1443 AH). This result is one day after the month of Rajab (i.e. the 1st of the following month) and it calculated the month Rajab to be 29 days rather than 30 days.

However, if the option passed to the Intl.DateTimeFormat() is ar-SA (i.e. arabic-Saudi Arabia), it will give the correct result. This is strange because the ar-SA locale uses the Islamic (Hijri) calendar by default.

Is this an error/bug or is it the correct internal workings of javascript?

Is there a more robust method to get the Islamic Date in Javascript other than using the 'ar-SA' locale (but not using external libraries)?

See the code example below:

I have tested this in node and chrome and it gives the same resulting discrepancy.

1let date = new Date("2022-03-03");
2let options = {year:'numeric', month:'long',day:'numeric'};
3
4let format = new Intl.DateTimeFormat('ar-SA-u-nu-latn', options);
5console.log("3 March 2022 with 'ar-SA'         :"+format.format(date)+ " ==&gt; means: 30 Rajab 1443 AH");
6
7format = new Intl.DateTimeFormat('en-u-ca-islamic-nu-latn', options);
8console.log("3 March 2022 with Islamic Calendar: "+format.format(date));

ANSWER

Answered 2022-Feb-06 at 07:29

There are three possible reasons for the "off by one" date problems you're seeing:

  1. Time zone mismatch between date initialization and date formatting
  2. Using the wrong variation of the Islamic calendar (JS implementations typically offer 5 different Islamic calendars!)
  3. Bugs in the ICU library used for JS's calendar calculations

I'll cover each of these below.

1. Time zone mismatch between date initialization and date formatting

The most common reason for off-by-one-day errors is (as @RobG noted in his comments above) a mismatch between the time zone used when declaring the Date value and the time zone used when formatting it in your desired calendar.

When you initialize a Date instance using an ISO 8601 string, the actual value stored in the Date instance is the number of milliseconds since January 1, 1970 UTC. Depending on your system time zone, new Date('2022-02-03') can be February 3 or February 2 in your system time zone. One way to evade this problem is to use UTC when formatting too:

1let date = new Date("2022-03-03");
2let options = {year:'numeric', month:'long',day:'numeric'};
3
4let format = new Intl.DateTimeFormat('ar-SA-u-nu-latn', options);
5console.log("3 March 2022 with 'ar-SA'         :"+format.format(date)+ " ==&gt; means: 30 Rajab 1443 AH");
6
7format = new Intl.DateTimeFormat('en-u-ca-islamic-nu-latn', options);
8console.log("3 March 2022 with Islamic Calendar: "+format.format(date));new Date('2022-03-03').toLocaleDateString('en-US');
9// outputs '3/2/2022' when run in San Francisco
10
11new Date('2022-03-03').toLocaleDateString('en-US', { timeZone: 'UTC' });
12// outputs '3/3/2022' as expected. UTC is used both for declaring and formatting.
13
14new Date('2022-03-03').toLocaleDateString(
15  'en-SA-u-ca-islamic-umalqura',
16  { timeZone: 'UTC', month: 'long', day: 'numeric', year: 'numeric' }
17);
18// outputs 'Rajab 30, 1443 AH' as expected
19

Note that I'm using Date.toLocaleDateString above, but the result is the same as if you'd used Intl.DateTimeFormat.format. The parameters and implementations are the same for both methods.

2. Using the wrong variation of the Islamic calendar (JS implementations typically offer 5 different Islamic calendars!)

A second and more subtle issue is that multiple variations of islamic calendars are used in JavaScript. The list of supported calendars is here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendars. Excerpting from that page, here are the supported Islamic calendar variations:

  • islamic
    • Islamic calendar
  • islamic-umalqura
    • Islamic calendar, Umm al-Qura
  • islamic-tbla
    • Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - astronomical epoch)
  • islamic-civil
    • Islamic calendar, tabular (intercalary years [2,5,7,10,13,16,18,21,24,26,29] - civil epoch)
  • islamic-rgsa
    • Islamic calendar, Saudi Arabia sighting

(There's also a deprecated islamicc calendar, but islamic-civil should be used instead.)

The default calendar for the ar-SA locale is the islamic-umalqura calendar, not the islamic calendar. To verify:

1let date = new Date("2022-03-03");
2let options = {year:'numeric', month:'long',day:'numeric'};
3
4let format = new Intl.DateTimeFormat('ar-SA-u-nu-latn', options);
5console.log("3 March 2022 with 'ar-SA'         :"+format.format(date)+ " ==&gt; means: 30 Rajab 1443 AH");
6
7format = new Intl.DateTimeFormat('en-u-ca-islamic-nu-latn', options);
8console.log("3 March 2022 with Islamic Calendar: "+format.format(date));new Date('2022-03-03').toLocaleDateString('en-US');
9// outputs '3/2/2022' when run in San Francisco
10
11new Date('2022-03-03').toLocaleDateString('en-US', { timeZone: 'UTC' });
12// outputs '3/3/2022' as expected. UTC is used both for declaring and formatting.
13
14new Date('2022-03-03').toLocaleDateString(
15  'en-SA-u-ca-islamic-umalqura',
16  { timeZone: 'UTC', month: 'long', day: 'numeric', year: 'numeric' }
17);
18// outputs 'Rajab 30, 1443 AH' as expected
19new Intl.DateTimeFormat('ar-SA').resolvedOptions();
20// {
21//   calendar: &quot;islamic-umalqura&quot;
22//   day: &quot;numeric&quot;
23//   locale: &quot;ar-SA&quot;
24//   month: &quot;numeric&quot;
25//   numberingSystem: &quot;arab&quot;
26//   timeZone: &quot;America/Los_Angeles&quot;
27//   year: &quot;numeric&quot;
28// }
29

Different Islamic calendar variations will yield different calendar dates. For example:

1let date = new Date("2022-03-03");
2let options = {year:'numeric', month:'long',day:'numeric'};
3
4let format = new Intl.DateTimeFormat('ar-SA-u-nu-latn', options);
5console.log("3 March 2022 with 'ar-SA'         :"+format.format(date)+ " ==&gt; means: 30 Rajab 1443 AH");
6
7format = new Intl.DateTimeFormat('en-u-ca-islamic-nu-latn', options);
8console.log("3 March 2022 with Islamic Calendar: "+format.format(date));new Date('2022-03-03').toLocaleDateString('en-US');
9// outputs '3/2/2022' when run in San Francisco
10
11new Date('2022-03-03').toLocaleDateString('en-US', { timeZone: 'UTC' });
12// outputs '3/3/2022' as expected. UTC is used both for declaring and formatting.
13
14new Date('2022-03-03').toLocaleDateString(
15  'en-SA-u-ca-islamic-umalqura',
16  { timeZone: 'UTC', month: 'long', day: 'numeric', year: 'numeric' }
17);
18// outputs 'Rajab 30, 1443 AH' as expected
19new Intl.DateTimeFormat('ar-SA').resolvedOptions();
20// {
21//   calendar: &quot;islamic-umalqura&quot;
22//   day: &quot;numeric&quot;
23//   locale: &quot;ar-SA&quot;
24//   month: &quot;numeric&quot;
25//   numberingSystem: &quot;arab&quot;
26//   timeZone: &quot;America/Los_Angeles&quot;
27//   year: &quot;numeric&quot;
28// }
29calendars = [&quot;islamic&quot;, &quot;islamic-umalqura&quot;, &quot;islamic-tbla&quot;, &quot;islamic-civil&quot;, &quot;islamic-rgsa&quot;];
30options = { timeZone: 'UTC', month: 'long', day: 'numeric', year: 'numeric' };
31date = new Date('2022-03-03');
32calendars.forEach(calendar =&gt; {
33  formatted = date.toLocaleDateString(`en-SA-u-ca-${calendar}`, options);
34  console.log(`${calendar}: ${formatted}`);
35});
36// The code above outputs the following:
37//   islamic: Shaʻban 1, 1443 AH
38//   islamic-umalqura: Rajab 30, 1443 AH
39//   islamic-tbla: Rajab 30, 1443 AH
40//   islamic-civil: Rajab 29, 1443 AH
41//   islamic-rgsa: Shaʻban 1, 1443 AH
42

3. Bugs in the ICU library used for JS's calendar calculations

A third possible reason for unexpected dates is if there's a bug in the calendar calculation code inside the JS engine. As far as I know, all major browsers delegate their calendar calculations to a library called ICU. If you're using the correct time zone and calendar variation and there's still a problem with the calculation, then you may want to try filing an issue in the ICU JIRA site: https://unicode-org.atlassian.net/jira/software/c/projects/ICU/issues/.

BTW, while answering this question I noticed a bug in the MDN documentation for the Intl.DateTimeFormat constructor where the list of supported calendars is wrong. I filed https://github.com/mdn/content/pull/12764 to fix the content. This PR has already been merged, but it may take a while for the production MDN site to be updated with the fixed content.

Source https://stackoverflow.com/questions/70996839

QUESTION

Class 'action' is not abstract and does not implement abstract member public abstract val actionId: Int defined in androidx.navigation.NavDirections

Asked 2022-Jan-29 at 12:44

I used version 2.4.0-alpha04 to conveniently use multi-backstack of navigation. (develop docs)

But I got the following error:

1Class 'ActionDialogToWriteRoutine' is not abstract and does not implement abstract member public abstract val actionId: Int defined in androidx.navigation.NavDirections
2

I first searched here to fix the error and found the question with the same error. (here)

I saw an answer in that link saying that the bug was fixed starting with v2.4.0-alpha02.

But I still get the same error.

So I'm posting the question again according to my situation.

What happened?

build.gradle[app]

1Class 'ActionDialogToWriteRoutine' is not abstract and does not implement abstract member public abstract val actionId: Int defined in androidx.navigation.NavDirections
2plugins {
3    id 'com.android.application'
4    id 'kotlin-android'
5    id 'kotlin-kapt'
6
7    // safe args
8    id 'androidx.navigation.safeargs.kotlin'
9}
10
11dependencies {
12    def lifecycle_version = &quot;2.3.1&quot;
13    def nav_version = &quot;2.4.0-alpha04&quot;
14
15    // AAC
16    implementation(&quot;androidx.fragment:fragment-ktx:1.3.4&quot;)
17
18    // Navigation Component
19    implementation &quot;androidx.navigation:navigation-fragment-ktx:$nav_version&quot;
20    implementation &quot;androidx.navigation:navigation-ui-ktx:$nav_version&quot;
21
22}
23

nav_graph.xml

1Class 'ActionDialogToWriteRoutine' is not abstract and does not implement abstract member public abstract val actionId: Int defined in androidx.navigation.NavDirections
2plugins {
3    id 'com.android.application'
4    id 'kotlin-android'
5    id 'kotlin-kapt'
6
7    // safe args
8    id 'androidx.navigation.safeargs.kotlin'
9}
10
11dependencies {
12    def lifecycle_version = &quot;2.3.1&quot;
13    def nav_version = &quot;2.4.0-alpha04&quot;
14
15    // AAC
16    implementation(&quot;androidx.fragment:fragment-ktx:1.3.4&quot;)
17
18    // Navigation Component
19    implementation &quot;androidx.navigation:navigation-fragment-ktx:$nav_version&quot;
20    implementation &quot;androidx.navigation:navigation-ui-ktx:$nav_version&quot;
21
22}
23&lt;navigation xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
24    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
25    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
26    android:id=&quot;@+id/nav_graph&quot;
27    app:startDestination=&quot;@id/calendar&quot;&gt;
28
29    &lt;include app:graph=&quot;@navigation/calendar&quot;/&gt;
30    &lt;include app:graph=&quot;@navigation/list&quot;/&gt;
31    &lt;include app:graph=&quot;@navigation/write_home&quot;/&gt;
32&lt;/navigation&gt;
33

write_home.xml

1Class 'ActionDialogToWriteRoutine' is not abstract and does not implement abstract member public abstract val actionId: Int defined in androidx.navigation.NavDirections
2plugins {
3    id 'com.android.application'
4    id 'kotlin-android'
5    id 'kotlin-kapt'
6
7    // safe args
8    id 'androidx.navigation.safeargs.kotlin'
9}
10
11dependencies {
12    def lifecycle_version = &quot;2.3.1&quot;
13    def nav_version = &quot;2.4.0-alpha04&quot;
14
15    // AAC
16    implementation(&quot;androidx.fragment:fragment-ktx:1.3.4&quot;)
17
18    // Navigation Component
19    implementation &quot;androidx.navigation:navigation-fragment-ktx:$nav_version&quot;
20    implementation &quot;androidx.navigation:navigation-ui-ktx:$nav_version&quot;
21
22}
23&lt;navigation xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
24    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
25    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
26    android:id=&quot;@+id/nav_graph&quot;
27    app:startDestination=&quot;@id/calendar&quot;&gt;
28
29    &lt;include app:graph=&quot;@navigation/calendar&quot;/&gt;
30    &lt;include app:graph=&quot;@navigation/list&quot;/&gt;
31    &lt;include app:graph=&quot;@navigation/write_home&quot;/&gt;
32&lt;/navigation&gt;
33&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
34&lt;navigation xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
35    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
36    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
37    android:id=&quot;@+id/write&quot;
38    app:startDestination=&quot;@id/home&quot;&gt;
39
40    &lt;fragment
41        android:id=&quot;@+id/home&quot;
42        android:name=&quot;com.example.writeweight.fragment.WriteRoutineHomeFragment&quot;
43        android:label=&quot;fragment_write_routine_home&quot;
44        tools:layout=&quot;@layout/fragment_write_routine_home&quot; &gt;
45        &lt;action
46            android:id=&quot;@+id/action_home_to_dialog&quot;
47            app:destination=&quot;@id/dialog&quot; /&gt;
48    &lt;/fragment&gt;
49    &lt;fragment
50        android:id=&quot;@+id/dialog&quot;
51        android:name=&quot;com.example.writeweight.fragment.BodyPartDialogFragment&quot;
52        android:label=&quot;BodyPartDialogFragment&quot;
53        tools:layout=&quot;@layout/fragment_body_part_dialog&quot;&gt;
54        &lt;action
55            android:id=&quot;@+id/action_dialog_to_write_routine&quot;
56            app:destination=&quot;@id/write_routine&quot; /&gt;
57    &lt;/fragment&gt;
58    &lt;fragment
59        android:id=&quot;@+id/write_routine&quot;
60        android:name=&quot;com.example.writeweight.fragment.WriteRoutineFragment&quot;
61        android:label=&quot;WriteRoutineFragment&quot;
62        tools:layout=&quot;@layout/fragment_writing_routine&quot;&gt;
63        &lt;argument
64            android:name=&quot;title&quot;
65            app:argType=&quot;string&quot;
66            app:nullable=&quot;true&quot;
67            android:defaultValue=&quot;@null&quot;/&gt;
68        &lt;argument
69            android:name=&quot;workout&quot;
70            app:argType=&quot;string&quot;
71            app:nullable=&quot;true&quot;
72            android:defaultValue=&quot;@null&quot;/&gt;
73        &lt;action
74            android:id=&quot;@+id/action_write_routine_to_workout_tab&quot;
75            app:destination=&quot;@id/workout_tab&quot; /&gt;
76    &lt;/fragment&gt;
77    &lt;fragment
78        android:id=&quot;@+id/workout_tab&quot;
79        android:name=&quot;com.example.writeweight.fragment.WorkoutListTabFragment&quot;
80        android:label=&quot;WorkoutListTabFragment&quot;
81        tools:layout=&quot;@layout/fragment_workout_list_tab&quot;&gt;
82        &lt;action
83            android:id=&quot;@+id/action_workout_tab_to_write_routine&quot;
84            app:destination=&quot;@id/write_routine&quot; /&gt;
85    &lt;/fragment&gt;
86&lt;/navigation&gt;
87

ANSWER

Answered 2021-Jul-31 at 20:28

in your app level build.gradle file replace

1Class 'ActionDialogToWriteRoutine' is not abstract and does not implement abstract member public abstract val actionId: Int defined in androidx.navigation.NavDirections
2plugins {
3    id 'com.android.application'
4    id 'kotlin-android'
5    id 'kotlin-kapt'
6
7    // safe args
8    id 'androidx.navigation.safeargs.kotlin'
9}
10
11dependencies {
12    def lifecycle_version = &quot;2.3.1&quot;
13    def nav_version = &quot;2.4.0-alpha04&quot;
14
15    // AAC
16    implementation(&quot;androidx.fragment:fragment-ktx:1.3.4&quot;)
17
18    // Navigation Component
19    implementation &quot;androidx.navigation:navigation-fragment-ktx:$nav_version&quot;
20    implementation &quot;androidx.navigation:navigation-ui-ktx:$nav_version&quot;
21
22}
23&lt;navigation xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
24    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
25    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
26    android:id=&quot;@+id/nav_graph&quot;
27    app:startDestination=&quot;@id/calendar&quot;&gt;
28
29    &lt;include app:graph=&quot;@navigation/calendar&quot;/&gt;
30    &lt;include app:graph=&quot;@navigation/list&quot;/&gt;
31    &lt;include app:graph=&quot;@navigation/write_home&quot;/&gt;
32&lt;/navigation&gt;
33&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
34&lt;navigation xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
35    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
36    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
37    android:id=&quot;@+id/write&quot;
38    app:startDestination=&quot;@id/home&quot;&gt;
39
40    &lt;fragment
41        android:id=&quot;@+id/home&quot;
42        android:name=&quot;com.example.writeweight.fragment.WriteRoutineHomeFragment&quot;
43        android:label=&quot;fragment_write_routine_home&quot;
44        tools:layout=&quot;@layout/fragment_write_routine_home&quot; &gt;
45        &lt;action
46            android:id=&quot;@+id/action_home_to_dialog&quot;
47            app:destination=&quot;@id/dialog&quot; /&gt;
48    &lt;/fragment&gt;
49    &lt;fragment
50        android:id=&quot;@+id/dialog&quot;
51        android:name=&quot;com.example.writeweight.fragment.BodyPartDialogFragment&quot;
52        android:label=&quot;BodyPartDialogFragment&quot;
53        tools:layout=&quot;@layout/fragment_body_part_dialog&quot;&gt;
54        &lt;action
55            android:id=&quot;@+id/action_dialog_to_write_routine&quot;
56            app:destination=&quot;@id/write_routine&quot; /&gt;
57    &lt;/fragment&gt;
58    &lt;fragment
59        android:id=&quot;@+id/write_routine&quot;
60        android:name=&quot;com.example.writeweight.fragment.WriteRoutineFragment&quot;
61        android:label=&quot;WriteRoutineFragment&quot;
62        tools:layout=&quot;@layout/fragment_writing_routine&quot;&gt;
63        &lt;argument
64            android:name=&quot;title&quot;
65            app:argType=&quot;string&quot;
66            app:nullable=&quot;true&quot;
67            android:defaultValue=&quot;@null&quot;/&gt;
68        &lt;argument
69            android:name=&quot;workout&quot;
70            app:argType=&quot;string&quot;
71            app:nullable=&quot;true&quot;
72            android:defaultValue=&quot;@null&quot;/&gt;
73        &lt;action
74            android:id=&quot;@+id/action_write_routine_to_workout_tab&quot;
75            app:destination=&quot;@id/workout_tab&quot; /&gt;
76    &lt;/fragment&gt;
77    &lt;fragment
78        android:id=&quot;@+id/workout_tab&quot;
79        android:name=&quot;com.example.writeweight.fragment.WorkoutListTabFragment&quot;
80        android:label=&quot;WorkoutListTabFragment&quot;
81        tools:layout=&quot;@layout/fragment_workout_list_tab&quot;&gt;
82        &lt;action
83            android:id=&quot;@+id/action_workout_tab_to_write_routine&quot;
84            app:destination=&quot;@id/write_routine&quot; /&gt;
85    &lt;/fragment&gt;
86&lt;/navigation&gt;
87plugins {
88    id 'androidx.navigation.safeargs.kotlin'
89}
90

with

1Class 'ActionDialogToWriteRoutine' is not abstract and does not implement abstract member public abstract val actionId: Int defined in androidx.navigation.NavDirections
2plugins {
3    id 'com.android.application'
4    id 'kotlin-android'
5    id 'kotlin-kapt'
6
7    // safe args
8    id 'androidx.navigation.safeargs.kotlin'
9}
10
11dependencies {
12    def lifecycle_version = &quot;2.3.1&quot;
13    def nav_version = &quot;2.4.0-alpha04&quot;
14
15    // AAC
16    implementation(&quot;androidx.fragment:fragment-ktx:1.3.4&quot;)
17
18    // Navigation Component
19    implementation &quot;androidx.navigation:navigation-fragment-ktx:$nav_version&quot;
20    implementation &quot;androidx.navigation:navigation-ui-ktx:$nav_version&quot;
21
22}
23&lt;navigation xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
24    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
25    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
26    android:id=&quot;@+id/nav_graph&quot;
27    app:startDestination=&quot;@id/calendar&quot;&gt;
28
29    &lt;include app:graph=&quot;@navigation/calendar&quot;/&gt;
30    &lt;include app:graph=&quot;@navigation/list&quot;/&gt;
31    &lt;include app:graph=&quot;@navigation/write_home&quot;/&gt;
32&lt;/navigation&gt;
33&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
34&lt;navigation xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
35    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
36    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
37    android:id=&quot;@+id/write&quot;
38    app:startDestination=&quot;@id/home&quot;&gt;
39
40    &lt;fragment
41        android:id=&quot;@+id/home&quot;
42        android:name=&quot;com.example.writeweight.fragment.WriteRoutineHomeFragment&quot;
43        android:label=&quot;fragment_write_routine_home&quot;
44        tools:layout=&quot;@layout/fragment_write_routine_home&quot; &gt;
45        &lt;action
46            android:id=&quot;@+id/action_home_to_dialog&quot;
47            app:destination=&quot;@id/dialog&quot; /&gt;
48    &lt;/fragment&gt;
49    &lt;fragment
50        android:id=&quot;@+id/dialog&quot;
51        android:name=&quot;com.example.writeweight.fragment.BodyPartDialogFragment&quot;
52        android:label=&quot;BodyPartDialogFragment&quot;
53        tools:layout=&quot;@layout/fragment_body_part_dialog&quot;&gt;
54        &lt;action
55            android:id=&quot;@+id/action_dialog_to_write_routine&quot;
56            app:destination=&quot;@id/write_routine&quot; /&gt;
57    &lt;/fragment&gt;
58    &lt;fragment
59        android:id=&quot;@+id/write_routine&quot;
60        android:name=&quot;com.example.writeweight.fragment.WriteRoutineFragment&quot;
61        android:label=&quot;WriteRoutineFragment&quot;
62        tools:layout=&quot;@layout/fragment_writing_routine&quot;&gt;
63        &lt;argument
64            android:name=&quot;title&quot;
65            app:argType=&quot;string&quot;
66            app:nullable=&quot;true&quot;
67            android:defaultValue=&quot;@null&quot;/&gt;
68        &lt;argument
69            android:name=&quot;workout&quot;
70            app:argType=&quot;string&quot;
71            app:nullable=&quot;true&quot;
72            android:defaultValue=&quot;@null&quot;/&gt;
73        &lt;action
74            android:id=&quot;@+id/action_write_routine_to_workout_tab&quot;
75            app:destination=&quot;@id/workout_tab&quot; /&gt;
76    &lt;/fragment&gt;
77    &lt;fragment
78        android:id=&quot;@+id/workout_tab&quot;
79        android:name=&quot;com.example.writeweight.fragment.WorkoutListTabFragment&quot;
80        android:label=&quot;WorkoutListTabFragment&quot;
81        tools:layout=&quot;@layout/fragment_workout_list_tab&quot;&gt;
82        &lt;action
83            android:id=&quot;@+id/action_workout_tab_to_write_routine&quot;
84            app:destination=&quot;@id/write_routine&quot; /&gt;
85    &lt;/fragment&gt;
86&lt;/navigation&gt;
87plugins {
88    id 'androidx.navigation.safeargs.kotlin'
89}
90plugins {
91    id 'androidx.navigation.safeargs'
92}
93

Source https://stackoverflow.com/questions/68596264

QUESTION

Flexible layout: Is this one possible?

Asked 2022-Jan-19 at 12:59

EDIT Keep in mind that each cell can have a different width and height. This is not the same thing as this post: CSS-only masonry layout, see guide lines of the reference picture:

enter image description here

there are about 19 columns and 17 rows made by guide lines and tiles placed in virtual 5×5 base grid overlap it in both axis.

I want something between a grid and a flex layout. Grids are limited by cell size and flex is more powerful, but (what I know of it) is limited to direction. I want to have different cell sizes, each 5 of them summing to the same width, and 5 columns summing to the same height. Like the image below.

Is there any way of achieving a similar layout using CSS?

enter image description here

This is all I got until now:

HTML:

1&lt;div class=&quot;calendar&quot;&gt;
2  &lt;div class=&quot;day day1&quot;&gt;1&lt;/div&gt;
3  &lt;div class=&quot;day day2&quot;&gt;2&lt;/div&gt;
4  &lt;div class=&quot;day day3&quot;&gt;3&lt;/div&gt;
5  &lt;div class=&quot;day day4&quot;&gt;4&lt;/div&gt;
6  &lt;div class=&quot;day day5&quot;&gt;5&lt;/div&gt;
7  &lt;div class=&quot;day day6&quot;&gt;6&lt;/div&gt;
8  &lt;div class=&quot;day day7&quot;&gt;7&lt;/div&gt;
9  &lt;div class=&quot;day day8&quot;&gt;8&lt;/div&gt;
10  &lt;div class=&quot;day day9&quot;&gt;9&lt;/div&gt;
11  &lt;div class=&quot;day day10&quot;&gt;10&lt;/div&gt;
12  &lt;div class=&quot;day day11&quot;&gt;11&lt;/div&gt;
13  &lt;div class=&quot;day day12&quot;&gt;12&lt;/div&gt;
14  &lt;div class=&quot;day day13&quot;&gt;13&lt;/div&gt;
15  &lt;div class=&quot;day day14&quot;&gt;14&lt;/div&gt;
16  &lt;div class=&quot;day day15&quot;&gt;15&lt;/div&gt;
17  &lt;div class=&quot;day day16&quot;&gt;16&lt;/div&gt;
18  &lt;div class=&quot;day day17&quot;&gt;17&lt;/div&gt;
19  &lt;div class=&quot;day day18&quot;&gt;18&lt;/div&gt;
20  &lt;div class=&quot;day day19&quot;&gt;19&lt;/div&gt;
21  &lt;div class=&quot;day day20&quot;&gt;20&lt;/div&gt;
22  &lt;div class=&quot;day day21&quot;&gt;21&lt;/div&gt;
23  &lt;div class=&quot;day day22&quot;&gt;22&lt;/div&gt;
24  &lt;div class=&quot;day day23&quot;&gt;23&lt;/div&gt;
25  &lt;div class=&quot;day day24&quot;&gt;24&lt;/div&gt;
26  &lt;div class=&quot;day day25&quot;&gt;25&lt;/div&gt;
27&lt;/div&gt;
28

CSS:

1&lt;div class=&quot;calendar&quot;&gt;
2  &lt;div class=&quot;day day1&quot;&gt;1&lt;/div&gt;
3  &lt;div class=&quot;day day2&quot;&gt;2&lt;/div&gt;
4  &lt;div class=&quot;day day3&quot;&gt;3&lt;/div&gt;
5  &lt;div class=&quot;day day4&quot;&gt;4&lt;/div&gt;
6  &lt;div class=&quot;day day5&quot;&gt;5&lt;/div&gt;
7  &lt;div class=&quot;day day6&quot;&gt;6&lt;/div&gt;
8  &lt;div class=&quot;day day7&quot;&gt;7&lt;/div&gt;
9  &lt;div class=&quot;day day8&quot;&gt;8&lt;/div&gt;
10  &lt;div class=&quot;day day9&quot;&gt;9&lt;/div&gt;
11  &lt;div class=&quot;day day10&quot;&gt;10&lt;/div&gt;
12  &lt;div class=&quot;day day11&quot;&gt;11&lt;/div&gt;
13  &lt;div class=&quot;day day12&quot;&gt;12&lt;/div&gt;
14  &lt;div class=&quot;day day13&quot;&gt;13&lt;/div&gt;
15  &lt;div class=&quot;day day14&quot;&gt;14&lt;/div&gt;
16  &lt;div class=&quot;day day15&quot;&gt;15&lt;/div&gt;
17  &lt;div class=&quot;day day16&quot;&gt;16&lt;/div&gt;
18  &lt;div class=&quot;day day17&quot;&gt;17&lt;/div&gt;
19  &lt;div class=&quot;day day18&quot;&gt;18&lt;/div&gt;
20  &lt;div class=&quot;day day19&quot;&gt;19&lt;/div&gt;
21  &lt;div class=&quot;day day20&quot;&gt;20&lt;/div&gt;
22  &lt;div class=&quot;day day21&quot;&gt;21&lt;/div&gt;
23  &lt;div class=&quot;day day22&quot;&gt;22&lt;/div&gt;
24  &lt;div class=&quot;day day23&quot;&gt;23&lt;/div&gt;
25  &lt;div class=&quot;day day24&quot;&gt;24&lt;/div&gt;
26  &lt;div class=&quot;day day25&quot;&gt;25&lt;/div&gt;
27&lt;/div&gt;
28.day {
29  margin: 10px;
30  color: white;
31}
32
33.calendar {
34  display: flex;
35  flex-direction: row;
36  flex-wrap: wrap;
37  align-content: flex-start;
38  width: 586px;
39  height: 586px;
40  border: solid 1px;
41}
42
43.day1 {
44  width: 87px;
45  height: 97px;
46  background: lightblue;
47}
48
49.day2 {
50  width: 151px;
51  height: 86px;
52  background: orange;
53}
54
55.day3 {
56  width: 86px;
57  height: 86px;
58  background: lightcoral;
59}
60
61.day4 {
62  width: 76px;
63  height: 118px;
64  background: lightgray;
65}
66
67.day5 {
68  width: 86px;
69  height: 86px;
70  background: lightblue;
71}
72
73.day6 {
74  width: 87px;
75  height: 86px;
76  background: lightsteelblue;
77}
78
79.day7 {
80  width: 108px;
81  height: 97px;
82  background: lightblue;
83}
84
85.day8 {
86  width: 129px;
87  height: 97px;
88  background: lightsteelblue;
89}
90
91.day9 {
92  width: 76px;
93  height: 65px;
94  background: orange;
95}
96
97.day10 {
98  width: 86px;
99  height: 128px;
100  background: cyan;
101}
102
103.day11 {
104  width: 75px;
105  height: 75px;
106  background: lightcoral;
107}
108
109.day12 {
110  width: 99px;
111  height: 96px;
112  background: lightgray;
113}
114
115.day13 {
116  width: 87px;
117  height: 96px;
118  background: lightcyan;
119}
120
121.day14 {
122  width: 139px;
123  height: 96px;
124  background: orange;
125}
126
127.day15 {
128  width: 86px;
129  height: 65px;
130  background: lightcoral;
131}
132
133.day16 {
134  width: 75px;
135  height: 118px;
136  background: orange;
137}
138
139.day17 {
140  width: 88px;
141  height: 97px;
142  background: lightcoral;
143}
144
145.day18 {
146  width: 161px;
147  height: 97px;
148  background: cyan;
149}
150
151.day19 {
152  width: 98px;
153  height: 118px;
154  background: lightgreen;
155}
156
157.day20 {
158  width: 64px;
159  height: 97px;
160  background: lightgray;
161}
162
163.day21 {
164  width: 108px;
165  height: 97px;
166  background: lightsteelblue;
167}
168
169.day22 {
170  width: 150px;
171  height: 97px;
172  background: lightblue;
173}
174
175.day23 {
176  width: 65px;
177  height: 97px;
178  background: lightgray;
179}
180
181.day24 {
182  width: 98px;
183  height: 75px;
184  background: orange;
185}
186
187.day25 {
188  width: 65px;
189  height: 97px;
190  background: lightblue;
191}
192

ANSWER

Answered 2021-Dec-25 at 17:08
basically use CSS GRID new answer

complete explanation in the previous answer below...

use also negative margin for the top ones like (1,4,19) and positive margin for the bottom ones

1&lt;div class=&quot;calendar&quot;&gt;
2  &lt;div class=&quot;day day1&quot;&gt;1&lt;/div&gt;
3  &lt;div class=&quot;day day2&quot;&gt;2&lt;/div&gt;
4  &lt;div class=&quot;day day3&quot;&gt;3&lt;/div&gt;
5  &lt;div class=&quot;day day4&quot;&gt;4&lt;/div&gt;
6  &lt;div class=&quot;day day5&quot;&gt;5&lt;/div&gt;
7  &lt;div class=&quot;day day6&quot;&gt;6&lt;/div&gt;
8  &lt;div class=&quot;day day7&quot;&gt;7&lt;/div&gt;
9  &lt;div class=&quot;day day8&quot;&gt;8&lt;/div&gt;
10  &lt;div class=&quot;day day9&quot;&gt;9&lt;/div&gt;
11  &lt;div class=&quot;day day10&quot;&gt;10&lt;/div&gt;
12  &lt;div class=&quot;day day11&quot;&gt;11&lt;/div&gt;
13  &lt;div class=&quot;day day12&quot;&gt;12&lt;/div&gt;
14  &lt;div class=&quot;day day13&quot;&gt;13&lt;/div&gt;
15  &lt;div class=&quot;day day14&quot;&gt;14&lt;/div&gt;
16  &lt;div class=&quot;day day15&quot;&gt;15&lt;/div&gt;
17  &lt;div class=&quot;day day16&quot;&gt;16&lt;/div&gt;
18  &lt;div class=&quot;day day17&quot;&gt;17&lt;/div&gt;
19  &lt;div class=&quot;day day18&quot;&gt;18&lt;/div&gt;
20  &lt;div class=&quot;day day19&quot;&gt;19&lt;/div&gt;
21  &lt;div class=&quot;day day20&quot;&gt;20&lt;/div&gt;
22  &lt;div class=&quot;day day21&quot;&gt;21&lt;/div&gt;
23  &lt;div class=&quot;day day22&quot;&gt;22&lt;/div&gt;
24  &lt;div class=&quot;day day23&quot;&gt;23&lt;/div&gt;
25  &lt;div class=&quot;day day24&quot;&gt;24&lt;/div&gt;
26  &lt;div class=&quot;day day25&quot;&gt;25&lt;/div&gt;
27&lt;/div&gt;
28.day {
29  margin: 10px;
30  color: white;
31}
32
33.calendar {
34  display: flex;
35  flex-direction: row;
36  flex-wrap: wrap;
37  align-content: flex-start;
38  width: 586px;
39  height: 586px;
40  border: solid 1px;
41}
42
43.day1 {
44  width: 87px;
45  height: 97px;
46  background: lightblue;
47}
48
49.day2 {
50  width: 151px;
51  height: 86px;
52  background: orange;
53}
54
55.day3 {
56  width: 86px;
57  height: 86px;
58  background: lightcoral;
59}
60
61.day4 {
62  width: 76px;
63  height: 118px;
64  background: lightgray;
65}
66
67.day5 {
68  width: 86px;
69  height: 86px;
70  background: lightblue;
71}
72
73.day6 {
74  width: 87px;
75  height: 86px;
76  background: lightsteelblue;
77}
78
79.day7 {
80  width: 108px;
81  height: 97px;
82  background: lightblue;
83}
84
85.day8 {
86  width: 129px;
87  height: 97px;
88  background: lightsteelblue;
89}
90
91.day9 {
92  width: 76px;
93  height: 65px;
94  background: orange;
95}
96
97.day10 {
98  width: 86px;
99  height: 128px;
100  background: cyan;
101}
102
103.day11 {
104  width: 75px;
105  height: 75px;
106  background: lightcoral;
107}
108
109.day12 {
110  width: 99px;
111  height: 96px;
112  background: lightgray;
113}
114
115.day13 {
116  width: 87px;
117  height: 96px;
118  background: lightcyan;
119}
120
121.day14 {
122  width: 139px;
123  height: 96px;
124  background: orange;
125}
126
127.day15 {
128  width: 86px;
129  height: 65px;
130  background: lightcoral;
131}
132
133.day16 {
134  width: 75px;
135  height: 118px;
136  background: orange;
137}
138
139.day17 {
140  width: 88px;
141  height: 97px;
142  background: lightcoral;
143}
144
145.day18 {
146  width: 161px;
147  height: 97px;
148  background: cyan;
149}
150
151.day19 {
152  width: 98px;
153  height: 118px;
154  background: lightgreen;
155}
156
157.day20 {
158  width: 64px;
159  height: 97px;
160  background: lightgray;
161}
162
163.day21 {
164  width: 108px;
165  height: 97px;
166  background: lightsteelblue;
167}
168
169.day22 {
170  width: 150px;
171  height: 97px;
172  background: lightblue;
173}
174
175.day23 {
176  width: 65px;
177  height: 97px;
178  background: lightgray;
179}
180
181.day24 {
182  width: 98px;
183  height: 75px;
184  background: orange;
185}
186
187.day25 {
188  width: 65px;
189  height: 97px;
190  background: lightblue;
191}
192... 
193
194/* here one example */
195.day1 {
196  grid-column: 1/2;
197  margin: 0 0 -2vh 0;
198}
199
200.day6 {
201  grid-column: 1/2;
202  margin: 2vh 0 0 0;
203}
204
205...
206

enter image description here

the new code

1&lt;div class=&quot;calendar&quot;&gt;
2  &lt;div class=&quot;day day1&quot;&gt;1&lt;/div&gt;
3  &lt;div class=&quot;day day2&quot;&gt;2&lt;/div&gt;
4  &lt;div class=&quot;day day3&quot;&gt;3&lt;/div&gt;
5  &lt;div class=&quot;day day4&quot;&gt;4&lt;/div&gt;
6  &lt;div class=&quot;day day5&quot;&gt;5&lt;/div&gt;
7  &lt;div class=&quot;day day6&quot;&gt;6&lt;/div&gt;
8  &lt;div class=&quot;day day7&quot;&gt;7&lt;/div&gt;
9  &lt;div class=&quot;day day8&quot;&gt;8&lt;/div&gt;
10  &lt;div class=&quot;day day9&quot;&gt;9&lt;/div&gt;
11  &lt;div class=&quot;day day10&quot;&gt;10&lt;/div&gt;
12  &lt;div class=&quot;day day11&quot;&gt;11&lt;/div&gt;
13  &lt;div class=&quot;day day12&quot;&gt;12&lt;/div&gt;
14  &lt;div class=&quot;day day13&quot;&gt;13&lt;/div&gt;
15  &lt;div class=&quot;day day14&quot;&gt;14&lt;/div&gt;
16  &lt;div class=&quot;day day15&quot;&gt;15&lt;/div&gt;
17  &lt;div class=&quot;day day16&quot;&gt;16&lt;/div&gt;
18  &lt;div class=&quot;day day17&quot;&gt;17&lt;/div&gt;
19  &lt;div class=&quot;day day18&quot;&gt;18&lt;/div&gt;
20  &lt;div class=&quot;day day19&quot;&gt;19&lt;/div&gt;
21  &lt;div class=&quot;day day20&quot;&gt;20&lt;/div&gt;
22  &lt;div class=&quot;day day21&quot;&gt;21&lt;/div&gt;
23  &lt;div class=&quot;day day22&quot;&gt;22&lt;/div&gt;
24  &lt;div class=&quot;day day23&quot;&gt;23&lt;/div&gt;
25  &lt;div class=&quot;day day24&quot;&gt;24&lt;/div&gt;
26  &lt;div class=&quot;day day25&quot;&gt;25&lt;/div&gt;
27&lt;/div&gt;
28.day {
29  margin: 10px;
30  color: white;
31}
32
33.calendar {
34  display: flex;
35  flex-direction: row;
36  flex-wrap: wrap;
37  align-content: flex-start;
38  width: 586px;
39  height: 586px;
40  border: solid 1px;
41}
42
43.day1 {
44  width: 87px;
45  height: 97px;
46  background: lightblue;
47}
48
49.day2 {
50  width: 151px;
51  height: 86px;
52  background: orange;
53}
54
55.day3 {
56  width: 86px;
57  height: 86px;
58  background: lightcoral;
59}
60
61.day4 {
62  width: 76px;
63  height: 118px;
64  background: lightgray;
65}
66
67.day5 {
68  width: 86px;
69  height: 86px;
70  background: lightblue;
71}
72
73.day6 {
74  width: 87px;
75  height: 86px;
76  background: lightsteelblue;
77}
78
79.day7 {
80  width: 108px;
81  height: 97px;
82  background: lightblue;
83}
84
85.day8 {
86  width: 129px;
87  height: 97px;
88  background: lightsteelblue;
89}
90
91.day9 {
92  width: 76px;
93  height: 65px;
94  background: orange;
95}
96
97.day10 {
98  width: 86px;
99  height: 128px;
100  background: cyan;
101}
102
103.day11 {
104  width: 75px;
105  height: 75px;
106  background: lightcoral;
107}
108
109.day12 {
110  width: 99px;
111  height: 96px;
112  background: lightgray;
113}
114
115.day13 {
116  width: 87px;
117  height: 96px;
118  background: lightcyan;
119}
120
121.day14 {
122  width: 139px;
123  height: 96px;
124  background: orange;
125}
126
127.day15 {
128  width: 86px;
129  height: 65px;
130  background: lightcoral;
131}
132
133.day16 {
134  width: 75px;
135  height: 118px;
136  background: orange;
137}
138
139.day17 {
140  width: 88px;
141  height: 97px;
142  background: lightcoral;
143}
144
145.day18 {
146  width: 161px;
147  height: 97px;
148  background: cyan;
149}
150
151.day19 {
152  width: 98px;
153  height: 118px;
154  background: lightgreen;
155}
156
157.day20 {
158  width: 64px;
159  height: 97px;
160  background: lightgray;
161}
162
163.day21 {
164  width: 108px;
165  height: 97px;
166  background: lightsteelblue;
167}
168
169.day22 {
170  width: 150px;
171  height: 97px;
172  background: lightblue;
173}
174
175.day23 {
176  width: 65px;
177  height: 97px;
178  background: lightgray;
179}
180
181.day24 {
182  width: 98px;
183  height: 75px;
184  background: orange;
185}
186
187.day25 {
188  width: 65px;
189  height: 97px;
190  background: lightblue;
191}
192... 
193
194/* here one example */
195.day1 {
196  grid-column: 1/2;
197  margin: 0 0 -2vh 0;
198}
199
200.day6 {
201  grid-column: 1/2;
202  margin: 2vh 0 0 0;
203}
204
205...
206body {
207  display: grid;
208  align-content: center;
209  justify-content: center;
210  height: 100vh;
211}
212
213.calendar {
214  display: grid;
215  gap: 0.5em;
216  height: 80vh;
217  width: 80vh;
218}
219
220.day {
221  border: 3px solid goldenrod;
222  padding: 0.1em;
223  display: grid;
224  place-items: center;
225  border-radius: 0.3em;
226  transition-duration: 1s;
227}
228
229.day:hover {
230  background-color: goldenrod;
231  color: white;
232  transition-duration: 0.5s;
233}
234
235.day1 {
236  grid-column: 1/2;
237  margin: 0 0 -2vh 0;
238}
239
240.day2 {
241  grid-column: 2/4;
242}
243
244.day3 {
245  grid-column: 4/5;
246}
247
248.day4 {
249  grid-column: 5/6;
250  margin: 0 0 -6vh 0;
251}
252
253.day5 {
254  grid-column: 6/7;
255}
256
257.day6 {
258  grid-column: 1/2;
259  margin: 2vh 0 0 0;
260}
261
262.day7 {
263  grid-column: 2/3;
264}
265
266.day8 {
267  grid-column: 3/5;
268}
269
270.day9 {
271  grid-column: 5/6;
272  margin: 6vh 0 0 0;
273}
274
275.day10 {
276  grid-column: 6/7;
277}
278
279.day11 {
280  grid-column: 1/2;
281}
282
283.day12 {
284  grid-column: 2/3;
285}
286
287.day13 {
288  grid-column: 3/4;
289}
290
291.day14 {
292  grid-column: 4/6;
293}
294
295.day15 {
296  grid-column: 6/7;
297}
298
299.day16 {
300  grid-column: 1/2;
301}
302
303.day17 {
304  grid-column: 2/3;
305}
306
307.day18 {
308  grid-column: 3/5;
309}
310
311.day19 {
312  grid-column: 5/6;
313  margin: 0 0 -3vh 0;
314}
315
316.day20 {
317  grid-column: 6/7;
318}
319
320.day21 {
321  grid-column: 1/2;
322}
323
324.day22 {
325  grid-column: 2/4;
326}
327
328.day23 {
329  grid-column: 4/5;
330}
331
332.day24 {
333  grid-column: 5/6;
334  margin: 3vh 0 0 0;
335}
336
337.day25 {
338  grid-column: 6/7;
339}
1&lt;div class=&quot;calendar&quot;&gt;
2  &lt;div class=&quot;day day1&quot;&gt;1&lt;/div&gt;
3  &lt;div class=&quot;day day2&quot;&gt;2&lt;/div&gt;
4  &lt;div class=&quot;day day3&quot;&gt;3&lt;/div&gt;
5  &lt;div class=&quot;day day4&quot;&gt;4&lt;/div&gt;
6  &lt;div class=&quot;day day5&quot;&gt;5&lt;/div&gt;
7  &lt;div class=&quot;day day6&quot;&gt;6&lt;/div&gt;
8  &lt;div class=&quot;day day7&quot;&gt;7&lt;/div&gt;
9  &lt;div class=&quot;day day8&quot;&gt;8&lt;/div&gt;
10  &lt;div class=&quot;day day9&quot;&gt;9&lt;/div&gt;
11  &lt;div class=&quot;day day10&quot;&gt;10&lt;/div&gt;
12  &lt;div class=&quot;day day11&quot;&gt;11&lt;/div&gt;
13  &lt;div class=&quot;day day12&quot;&gt;12&lt;/div&gt;
14  &lt;div class=&quot;day day13&quot;&gt;13&lt;/div&gt;
15  &lt;div class=&quot;day day14&quot;&gt;14&lt;/div&gt;
16  &lt;div class=&quot;day day15&quot;&gt;15&lt;/div&gt;
17  &lt;div class=&quot;day day16&quot;&gt;16&lt;/div&gt;
18  &lt;div class=&quot;day day17&quot;&gt;17&lt;/div&gt;
19  &lt;div class=&quot;day day18&quot;&gt;18&lt;/div&gt;
20  &lt;div class=&quot;day day19&quot;&gt;19&lt;/div&gt;
21  &lt;div class=&quot;day day20&quot;&gt;20&lt;/div&gt;
22  &lt;div class=&quot;day day21&quot;&gt;21&lt;/div&gt;
23  &lt;div class=&quot;day day22&quot;&gt;22&lt;/div&gt;
24  &lt;div class=&quot;day day23&quot;&gt;23&lt;/div&gt;
25  &lt;div class=&quot;day day24&quot;&gt;24&lt;/div&gt;
26  &lt;div class=&quot;day day25&quot;&gt;25&lt;/div&gt;
27&lt;/div&gt;
28.day {
29  margin: 10px;
30  color: white;
31}
32
33.calendar {
34  display: flex;
35  flex-direction: row;
36  flex-wrap: wrap;
37  align-content: flex-start;
38  width: 586px;
39  height: 586px;
40  border: solid 1px;
41}
42
43.day1 {
44  width: 87px;
45  height: 97px;
46  background: lightblue;
47}
48
49.day2 {
50  width: 151px;
51  height: 86px;
52  background: orange;
53}
54
55.day3 {
56  width: 86px;
57  height: 86px;
58  background: lightcoral;
59}
60
61.day4 {
62  width: 76px;
63  height: 118px;
64  background: lightgray;
65}
66
67.day5 {
68  width: 86px;
69  height: 86px;
70  background: lightblue;
71}
72
73.day6 {
74  width: 87px;
75  height: 86px;
76  background: lightsteelblue;
77}
78
79.day7 {
80  width: 108px;
81  height: 97px;
82  background: lightblue;
83}
84
85.day8 {
86  width: 129px;
87  height: 97px;
88  background: lightsteelblue;
89}
90
91.day9 {
92  width: 76px;
93  height: 65px;
94  background: orange;
95}
96
97.day10 {
98  width: 86px;
99  height: 128px;
100  background: cyan;
101}
102
103.day11 {
104  width: 75px;
105  height: 75px;
106  background: lightcoral;
107}
108
109.day12 {
110  width: 99px;
111  height: 96px;
112  background: lightgray;
113}
114
115.day13 {
116  width: 87px;
117  height: 96px;
118  background: lightcyan;
119}
120
121.day14 {
122  width: 139px;
123  height: 96px;
124  background: orange;
125}
126
127.day15 {
128  width: 86px;
129  height: 65px;
130  background: lightcoral;
131}
132
133.day16 {
134  width: 75px;
135  height: 118px;
136  background: orange;
137}
138
139.day17 {
140  width: 88px;
141  height: 97px;
142  background: lightcoral;
143}
144
145.day18 {
146  width: 161px;
147  height: 97px;
148  background: cyan;
149}
150
151.day19 {
152  width: 98px;
153  height: 118px;
154  background: lightgreen;
155}
156
157.day20 {
158  width: 64px;
159  height: 97px;
160  background: lightgray;
161}
162
163.day21 {
164  width: 108px;
165  height: 97px;
166  background: lightsteelblue;
167}
168
169.day22 {
170  width: 150px;
171  height: 97px;
172  background: lightblue;
173}
174
175.day23 {
176  width: 65px;
177  height: 97px;
178  background: lightgray;
179}
180
181.day24 {
182  width: 98px;
183  height: 75px;
184  background: orange;
185}
186
187.day25 {
188  width: 65px;
189  height: 97px;
190  background: lightblue;
191}
192... 
193
194/* here one example */
195.day1 {
196  grid-column: 1/2;
197  margin: 0 0 -2vh 0;
198}
199
200.day6 {
201  grid-column: 1/2;
202  margin: 2vh 0 0 0;
203}
204
205...
206body {
207  display: grid;
208  align-content: center;
209  justify-content: center;
210  height: 100vh;
211}
212
213.calendar {
214  display: grid;
215  gap: 0.5em;
216  height: 80vh;
217  width: 80vh;
218}
219
220.day {
221  border: 3px solid goldenrod;
222  padding: 0.1em;
223  display: grid;
224  place-items: center;
225  border-radius: 0.3em;
226  transition-duration: 1s;
227}
228
229.day:hover {
230  background-color: goldenrod;
231  color: white;
232  transition-duration: 0.5s;
233}
234
235.day1 {
236  grid-column: 1/2;
237  margin: 0 0 -2vh 0;
238}
239
240.day2 {
241  grid-column: 2/4;
242}
243
244.day3 {
245  grid-column: 4/5;
246}
247
248.day4 {
249  grid-column: 5/6;
250  margin: 0 0 -6vh 0;
251}
252
253.day5 {
254  grid-column: 6/7;
255}
256
257.day6 {
258  grid-column: 1/2;
259  margin: 2vh 0 0 0;
260}
261
262.day7 {
263  grid-column: 2/3;
264}
265
266.day8 {
267  grid-column: 3/5;
268}
269
270.day9 {
271  grid-column: 5/6;
272  margin: 6vh 0 0 0;
273}
274
275.day10 {
276  grid-column: 6/7;
277}
278
279.day11 {
280  grid-column: 1/2;
281}
282
283.day12 {
284  grid-column: 2/3;
285}
286
287.day13 {
288  grid-column: 3/4;
289}
290
291.day14 {
292  grid-column: 4/6;
293}
294
295.day15 {
296  grid-column: 6/7;
297}
298
299.day16 {
300  grid-column: 1/2;
301}
302
303.day17 {
304  grid-column: 2/3;
305}
306
307.day18 {
308  grid-column: 3/5;
309}
310
311.day19 {
312  grid-column: 5/6;
313  margin: 0 0 -3vh 0;
314}
315
316.day20 {
317  grid-column: 6/7;
318}
319
320.day21 {
321  grid-column: 1/2;
322}
323
324.day22 {
325  grid-column: 2/4;
326}
327
328.day23 {
329  grid-column: 4/5;
330}
331
332.day24 {
333  grid-column: 5/6;
334  margin: 3vh 0 0 0;
335}
336
337.day25 {
338  grid-column: 6/7;
339}&lt;!DOCTYPE html&gt;
340&lt;html lang="en"&gt;
341
342&lt;head&gt;
343  &lt;meta charset="UTF-8"&gt;
344  &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
345  &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
346  &lt;title&gt;Document&lt;/title&gt;
347  &lt;link rel="stylesheet" href="style.css"&gt;
348&lt;/head&gt;
349
350&lt;body&gt;
351  &lt;div class="calendar"&gt;
352    &lt;div class="day day1"&gt;1&lt;/div&gt;
353    &lt;div class="day day2"&gt;2&lt;/div&gt;
354    &lt;div class="day day3"&gt;3&lt;/div&gt;
355    &lt;div class="day day4"&gt;4&lt;/div&gt;
356    &lt;div class="day day5"&gt;5&lt;/div&gt;
357    &lt;div class="day day6"&gt;6&lt;/div&gt;
358    &lt;div class="day day7"&gt;7&lt;/div&gt;
359    &lt;div class="day day8"&gt;8&lt;/div&gt;
360    &lt;div class="day day9"&gt;9&lt;/div&gt;
361    &lt;div class="day day10"&gt;10&lt;/div&gt;
362    &lt;div class="day day11"&gt;11&lt;/div&gt;
363    &lt;div class="day day12"&gt;12&lt;/div&gt;
364    &lt;div class="day day13"&gt;13&lt;/div&gt;
365    &lt;div class="day day14"&gt;14&lt;/div&gt;
366    &lt;div class="day day15"&gt;15&lt;/div&gt;
367    &lt;div class="day day16"&gt;16&lt;/div&gt;
368    &lt;div class="day day17"&gt;17&lt;/div&gt;
369    &lt;div class="day day18"&gt;18&lt;/div&gt;
370    &lt;div class="day day19"&gt;19&lt;/div&gt;
371    &lt;div class="day day20"&gt;20&lt;/div&gt;
372    &lt;div class="day day21"&gt;21&lt;/div&gt;
373    &lt;div class="day day22"&gt;22&lt;/div&gt;
374    &lt;div class="day day23"&gt;23&lt;/div&gt;
375    &lt;div class="day day24"&gt;24&lt;/div&gt;
376    &lt;div class="day day25"&gt;25&lt;/div&gt;
377  &lt;/div&gt;
378&lt;/body&gt;
379
380&lt;/html&gt;
previous answer

one time I put the display: grid to the parent element (in this case .calendar)

now i can use in all day1, day2, day3...

...this css property grid-column

that is a shorthand for grid-column-start and grid-column-end

using the FireFox DevTools i click the grid button in the code, that make appear me a grid visualizer...

in the paper, I start thinking about... and I find that the best way is creating a 7 columns grid-based.

enter image description here

here the previus code

1&lt;div class=&quot;calendar&quot;&gt;
2  &lt;div class=&quot;day day1&quot;&gt;1&lt;/div&gt;
3  &lt;div class=&quot;day day2&quot;&gt;2&lt;/div&gt;
4  &lt;div class=&quot;day day3&quot;&gt;3&lt;/div&gt;
5  &lt;div class=&quot;day day4&quot;&gt;4&lt;/div&gt;
6  &lt;div class=&quot;day day5&quot;&gt;5&lt;/div&gt;
7  &lt;div class=&quot;day day6&quot;&gt;6&lt;/div&gt;
8  &lt;div class=&quot;day day7&quot;&gt;7&lt;/div&gt;
9  &lt;div class=&quot;day day8&quot;&gt;8&lt;/div&gt;
10  &lt;div class=&quot;day day9&quot;&gt;9&lt;/div&gt;
11  &lt;div class=&quot;day day10&quot;&gt;10&lt;/div&gt;
12  &lt;div class=&quot;day day11&quot;&gt;11&lt;/div&gt;
13  &lt;div class=&quot;day day12&quot;&gt;12&lt;/div&gt;
14  &lt;div class=&quot;day day13&quot;&gt;13&lt;/div&gt;
15  &lt;div class=&quot;day day14&quot;&gt;14&lt;/div&gt;
16  &lt;div class=&quot;day day15&quot;&gt;15&lt;/div&gt;
17  &lt;div class=&quot;day day16&quot;&gt;16&lt;/div&gt;
18  &lt;div class=&quot;day day17&quot;&gt;17&lt;/div&gt;
19  &lt;div class=&quot;day day18&quot;&gt;18&lt;/div&gt;
20  &lt;div class=&quot;day day19&quot;&gt;19&lt;/div&gt;
21  &lt;div class=&quot;day day20&quot;&gt;20&lt;/div&gt;
22  &lt;div class=&quot;day day21&quot;&gt;21&lt;/div&gt;
23  &lt;div class=&quot;day day22&quot;&gt;22&lt;/div&gt;
24  &lt;div class=&quot;day day23&quot;&gt;23&lt;/div&gt;
25  &lt;div class=&quot;day day24&quot;&gt;24&lt;/div&gt;
26  &lt;div class=&quot;day day25&quot;&gt;25&lt;/div&gt;
27&lt;/div&gt;
28.day {
29  margin: 10px;
30  color: white;
31}
32
33.calendar {
34  display: flex;
35  flex-direction: row;
36  flex-wrap: wrap;
37  align-content: flex-start;
38  width: 586px;
39  height: 586px;
40  border: solid 1px;
41}
42
43.day1 {
44  width: 87px;
45  height: 97px;
46  background: lightblue;
47}
48
49.day2 {
50  width: 151px;
51  height: 86px;
52  background: orange;
53}
54
55.day3 {
56  width: 86px;
57  height: 86px;
58  background: lightcoral;
59}
60
61.day4 {
62  width: 76px;
63  height: 118px;
64  background: lightgray;
65}
66
67.day5 {
68  width: 86px;
69  height: 86px;
70  background: lightblue;
71}
72
73.day6 {
74  width: 87px;
75  height: 86px;
76  background: lightsteelblue;
77}
78
79.day7 {
80  width: 108px;
81  height: 97px;
82  background: lightblue;
83}
84
85.day8 {
86  width: 129px;
87  height: 97px;
88  background: lightsteelblue;
89}
90
91.day9 {
92  width: 76px;
93  height: 65px;
94  background: orange;
95}
96
97.day10 {
98  width: 86px;
99  height: 128px;
100  background: cyan;
101}
102
103.day11 {
104  width: 75px;
105  height: 75px;
106  background: lightcoral;
107}
108
109.day12 {
110  width: 99px;
111  height: 96px;
112  background: lightgray;
113}
114
115.day13 {
116  width: 87px;
117  height: 96px;
118  background: lightcyan;
119}
120
121.day14 {
122  width: 139px;
123  height: 96px;
124  background: orange;
125}
126
127.day15 {
128  width: 86px;
129  height: 65px;
130  background: lightcoral;
131}
132
133.day16 {
134  width: 75px;
135  height: 118px;
136  background: orange;
137}
138
139.day17 {
140  width: 88px;
141  height: 97px;
142  background: lightcoral;
143}
144
145.day18 {
146  width: 161px;
147  height: 97px;
148  background: cyan;
149}
150
151.day19 {
152  width: 98px;
153  height: 118px;
154  background: lightgreen;
155}
156
157.day20 {
158  width: 64px;
159  height: 97px;
160  background: lightgray;
161}
162
163.day21 {
164  width: 108px;
165  height: 97px;
166  background: lightsteelblue;
167}
168
169.day22 {
170  width: 150px;
171  height: 97px;
172  background: lightblue;
173}
174
175.day23 {
176  width: 65px;
177  height: 97px;
178  background: lightgray;
179}
180
181.day24 {
182  width: 98px;
183  height: 75px;
184  background: orange;
185}
186
187.day25 {
188  width: 65px;
189  height: 97px;
190  background: lightblue;
191}
192... 
193
194/* here one example */
195.day1 {
196  grid-column: 1/2;
197  margin: 0 0 -2vh 0;
198}
199
200.day6 {
201  grid-column: 1/2;
202  margin: 2vh 0 0 0;
203}
204
205...
206body {
207  display: grid;
208  align-content: center;
209  justify-content: center;
210  height: 100vh;
211}
212
213.calendar {
214  display: grid;
215  gap: 0.5em;
216  height: 80vh;
217  width: 80vh;
218}
219
220.day {
221  border: 3px solid goldenrod;
222  padding: 0.1em;
223  display: grid;
224  place-items: center;
225  border-radius: 0.3em;
226  transition-duration: 1s;
227}
228
229.day:hover {
230  background-color: goldenrod;
231  color: white;
232  transition-duration: 0.5s;
233}
234
235.day1 {
236  grid-column: 1/2;
237  margin: 0 0 -2vh 0;
238}
239
240.day2 {
241  grid-column: 2/4;
242}
243
244.day3 {
245  grid-column: 4/5;
246}
247
248.day4 {
249  grid-column: 5/6;
250  margin: 0 0 -6vh 0;
251}
252
253.day5 {
254  grid-column: 6/7;
255}
256
257.day6 {
258  grid-column: 1/2;
259  margin: 2vh 0 0 0;
260}
261
262.day7 {
263  grid-column: 2/3;
264}
265
266.day8 {
267  grid-column: 3/5;
268}
269
270.day9 {
271  grid-column: 5/6;
272  margin: 6vh 0 0 0;
273}
274
275.day10 {
276  grid-column: 6/7;
277}
278
279.day11 {
280  grid-column: 1/2;
281}
282
283.day12 {
284  grid-column: 2/3;
285}
286
287.day13 {
288  grid-column: 3/4;
289}
290
291.day14 {
292  grid-column: 4/6;
293}
294
295.day15 {
296  grid-column: 6/7;
297}
298
299.day16 {
300  grid-column: 1/2;
301}
302
303.day17 {
304  grid-column: 2/3;
305}
306
307.day18 {
308  grid-column: 3/5;
309}
310
311.day19 {
312  grid-column: 5/6;
313  margin: 0 0 -3vh 0;
314}
315
316.day20 {
317  grid-column: 6/7;
318}
319
320.day21 {
321  grid-column: 1/2;
322}
323
324.day22 {
325  grid-column: 2/4;
326}
327
328.day23 {
329  grid-column: 4/5;
330}
331
332.day24 {
333  grid-column: 5/6;
334  margin: 3vh 0 0 0;
335}
336
337.day25 {
338  grid-column: 6/7;
339}&lt;!DOCTYPE html&gt;
340&lt;html lang="en"&gt;
341
342&lt;head&gt;
343  &lt;meta charset="UTF-8"&gt;
344  &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
345  &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
346  &lt;title&gt;Document&lt;/title&gt;
347  &lt;link rel="stylesheet" href="style.css"&gt;
348&lt;/head&gt;
349
350&lt;body&gt;
351  &lt;div class="calendar"&gt;
352    &lt;div class="day day1"&gt;1&lt;/div&gt;
353    &lt;div class="day day2"&gt;2&lt;/div&gt;
354    &lt;div class="day day3"&gt;3&lt;/div&gt;
355    &lt;div class="day day4"&gt;4&lt;/div&gt;
356    &lt;div class="day day5"&gt;5&lt;/div&gt;
357    &lt;div class="day day6"&gt;6&lt;/div&gt;
358    &lt;div class="day day7"&gt;7&lt;/div&gt;
359    &lt;div class="day day8"&gt;8&lt;/div&gt;
360    &lt;div class="day day9"&gt;9&lt;/div&gt;
361    &lt;div class="day day10"&gt;10&lt;/div&gt;
362    &lt;div class="day day11"&gt;11&lt;/div&gt;
363    &lt;div class="day day12"&gt;12&lt;/div&gt;
364    &lt;div class="day day13"&gt;13&lt;/div&gt;
365    &lt;div class="day day14"&gt;14&lt;/div&gt;
366    &lt;div class="day day15"&gt;15&lt;/div&gt;
367    &lt;div class="day day16"&gt;16&lt;/div&gt;
368    &lt;div class="day day17"&gt;17&lt;/div&gt;
369    &lt;div class="day day18"&gt;18&lt;/div&gt;
370    &lt;div class="day day19"&gt;19&lt;/div&gt;
371    &lt;div class="day day20"&gt;20&lt;/div&gt;
372    &lt;div class="day day21"&gt;21&lt;/div&gt;
373    &lt;div class="day day22"&gt;22&lt;/div&gt;
374    &lt;div class="day day23"&gt;23&lt;/div&gt;
375    &lt;div class="day day24"&gt;24&lt;/div&gt;
376    &lt;div class="day day25"&gt;25&lt;/div&gt;
377  &lt;/div&gt;
378&lt;/body&gt;
379
380&lt;/html&gt;body {
381  display: grid;
382  align-content: center;
383  justify-content: center;
384  height: 100vh;
385}
386
387.calendar {
388  display: grid;
389  gap: 0.5em;
390  height: 80vh;
391  width: 80vh;
392}
393
394.day {
395  border: 2px solid goldenrod;
396  padding: 0.1em;
397  display: grid;
398  place-items: center;
399  border-radius: 0.3em;
400  transition-duration: 1s;
401}
402
403.day:hover {
404  background-color: goldenrod;
405  color: white;
406  transition-duration: 0.5s;
407}
408
409.day1 {
410  grid-column: 1/2;
411}
412
413.day2 {
414  grid-column: 2/4;
415}
416
417.day3 {
418  grid-column: 4/5;
419}
420
421.day4 {
422  grid-column: 5/6;
423}
424
425.day5 {
426  grid-column: 6/7;
427}
428
429.day6 {
430  grid-column: 1/2;
431}
432
433.day7 {
434  grid-column: 2/3;
435}
436
437.day8 {
438  grid-column: 3/5;
439}
440
441.day9 {
442  grid-column: 5/6;
443}
444
445.day10 {
446  grid-column: 6/7;
447}
448
449.day11 {
450  grid-column: 1/2;
451}
452
453.day12 {
454  grid-column: 2/3;
455}
456
457.day13 {
458  grid-column: 3/4;
459}
460
461.day14 {
462  grid-column: 4/6;
463}
464
465.day15 {
466  grid-column: 6/7;
467}
468
469.day16 {
470  grid-column: 1/2;
471}
472
473.day17 {
474  grid-column: 2/3;
475}
476
477.day18 {
478  grid-column: 3/5;
479}
480
481.day19 {
482  grid-column: 5/6;
483}
484
485.day20 {
486  grid-column: 6/7;
487}
488
489.day21 {
490  grid-column: 1/2;
491}
492
493.day22 {
494  grid-column: 2/4;
495}
496
497.day23 {
498  grid-column: 4/5;
499}
500
501.day24 {
502  grid-column: 5/6;
503}
504
505.day25 {
506  grid-column: 6/7;
507}
1&lt;div class=&quot;calendar&quot;&gt;
2  &lt;div class=&quot;day day1&quot;&gt;1&lt;/div&gt;
3  &lt;div class=&quot;day day2&quot;&gt;2&lt;/div&gt;
4  &lt;div class=&quot;day day3&quot;&gt;3&lt;/div&gt;
5  &lt;div class=&quot;day day4&quot;&gt;4&lt;/div&gt;
6  &lt;div class=&quot;day day5&quot;&gt;5&lt;/div&gt;
7  &lt;div class=&quot;day day6&quot;&gt;6&lt;/div&gt;
8  &lt;div class=&quot;day day7&quot;&gt;7&lt;/div&gt;
9  &lt;div class=&quot;day day8&quot;&gt;8&lt;/div&gt;
10  &lt;div class=&quot;day day9&quot;&gt;9&lt;/div&gt;
11  &lt;div class=&quot;day day10&quot;&gt;10&lt;/div&gt;
12  &lt;div class=&quot;day day11&quot;&gt;11&lt;/div&gt;
13  &lt;div class=&quot;day day12&quot;&gt;12&lt;/div&gt;
14  &lt;div class=&quot;day day13&quot;&gt;13&lt;/div&gt;
15  &lt;div class=&quot;day day14&quot;&gt;14&lt;/div&gt;
16  &lt;div class=&quot;day day15&quot;&gt;15&lt;/div&gt;
17  &lt;div class=&quot;day day16&quot;&gt;16&lt;/div&gt;
18  &lt;div class=&quot;day day17&quot;&gt;17&lt;/div&gt;
19  &lt;div class=&quot;day day18&quot;&gt;18&lt;/div&gt;
20  &lt;div class=&quot;day day19&quot;&gt;19&lt;/div&gt;
21  &lt;div class=&quot;day day20&quot;&gt;20&lt;/div&gt;
22  &lt;div class=&quot;day day21&quot;&gt;21&lt;/div&gt;
23  &lt;div class=&quot;day day22&quot;&gt;22&lt;/div&gt;
24  &lt;div class=&quot;day day23&quot;&gt;23&lt;/div&gt;
25  &lt;div class=&quot;day day24&quot;&gt;24&lt;/div&gt;
26  &lt;div class=&quot;day day25&quot;&gt;25&lt;/div&gt;
27&lt;/div&gt;
28.day {
29  margin: 10px;
30  color: white;
31}
32
33.calendar {
34  display: flex;
35  flex-direction: row;
36  flex-wrap: wrap;
37  align-content: flex-start;
38  width: 586px;
39  height: 586px;
40  border: solid 1px;
41}
42
43.day1 {
44  width: 87px;
45  height: 97px;
46  background: lightblue;
47}
48
49.day2 {
50  width: 151px;
51  height: 86px;
52  background: orange;
53}
54
55.day3 {
56  width: 86px;
57  height: 86px;
58  background: lightcoral;
59}
60
61.day4 {
62  width: 76px;
63  height: 118px;
64  background: lightgray;
65}
66
67.day5 {
68  width: 86px;
69  height: 86px;
70  background: lightblue;
71}
72
73.day6 {
74  width: 87px;
75  height: 86px;
76  background: lightsteelblue;
77}
78
79.day7 {
80  width: 108px;
81  height: 97px;
82  background: lightblue;
83}
84
85.day8 {
86  width: 129px;
87  height: 97px;
88  background: lightsteelblue;
89}
90
91.day9 {
92  width: 76px;
93  height: 65px;
94  background: orange;
95}
96
97.day10 {
98  width: 86px;
99  height: 128px;
100  background: cyan;
101}
102
103.day11 {
104  width: 75px;
105  height: 75px;
106  background: lightcoral;
107}
108
109.day12 {
110  width: 99px;
111  height: 96px;
112  background: lightgray;
113}
114
115.day13 {
116  width: 87px;
117  height: 96px;
118  background: lightcyan;
119}
120
121.day14 {
122  width: 139px;
123  height: 96px;
124  background: orange;
125}
126
127.day15 {
128  width: 86px;
129  height: 65px;
130  background: lightcoral;
131}
132
133.day16 {
134  width: 75px;
135  height: 118px;
136  background: orange;
137}
138
139.day17 {
140  width: 88px;
141  height: 97px;
142  background: lightcoral;
143}
144
145.day18 {
146  width: 161px;
147  height: 97px;
148  background: cyan;
149}
150
151.day19 {
152  width: 98px;
153  height: 118px;
154  background: lightgreen;
155}
156
157.day20 {
158  width: 64px;
159  height: 97px;
160  background: lightgray;
161}
162
163.day21 {
164  width: 108px;
165  height: 97px;
166  background: lightsteelblue;
167}
168
169.day22 {
170  width: 150px;
171  height: 97px;
172  background: lightblue;
173}
174
175.day23 {
176  width: 65px;
177  height: 97px;
178  background: lightgray;
179}
180
181.day24 {
182  width: 98px;
183  height: 75px;
184  background: orange;
185}
186
187.day25 {
188  width: 65px;
189  height: 97px;
190  background: lightblue;
191}
192... 
193
194/* here one example */
195.day1 {
196  grid-column: 1/2;
197  margin: 0 0 -2vh 0;
198}
199
200.day6 {
201  grid-column: 1/2;
202  margin: 2vh 0 0 0;
203}
204
205...
206body {
207  display: grid;
208  align-content: center;
209  justify-content: center;
210  height: 100vh;
211}
212
213.calendar {
214  display: grid;
215  gap: 0.5em;
216  height: 80vh;
217  width: 80vh;
218}
219
220.day {
221  border: 3px solid goldenrod;
222  padding: 0.1em;
223  display: grid;
224  place-items: center;
225  border-radius: 0.3em;
226  transition-duration: 1s;
227}
228
229.day:hover {
230  background-color: goldenrod;
231  color: white;
232  transition-duration: 0.5s;
233}
234
235.day1 {
236  grid-column: 1/2;
237  margin: 0 0 -2vh 0;
238}
239
240.day2 {
241  grid-column: 2/4;
242}
243
244.day3 {
245  grid-column: 4/5;
246}
247
248.day4 {
249  grid-column: 5/6;
250  margin: 0 0 -6vh 0;
251}
252
253.day5 {
254  grid-column: 6/7;
255}
256
257.day6 {
258  grid-column: 1/2;
259  margin: 2vh 0 0 0;
260}
261
262.day7 {
263  grid-column: 2/3;
264}
265
266.day8 {
267  grid-column: 3/5;
268}
269
270.day9 {
271  grid-column: 5/6;
272  margin: 6vh 0 0 0;
273}
274
275.day10 {
276  grid-column: 6/7;
277}
278
279.day11 {
280  grid-column: 1/2;
281}
282
283.day12 {
284  grid-column: 2/3;
285}
286
287.day13 {
288  grid-column: 3/4;
289}
290
291.day14 {
292  grid-column: 4/6;
293}
294
295.day15 {
296  grid-column: 6/7;
297}
298
299.day16 {
300  grid-column: 1/2;
301}
302
303.day17 {
304  grid-column: 2/3;
305}
306
307.day18 {
308  grid-column: 3/5;
309}
310
311.day19 {
312  grid-column: 5/6;
313  margin: 0 0 -3vh 0;
314}
315
316.day20 {
317  grid-column: 6/7;
318}
319
320.day21 {
321  grid-column: 1/2;
322}
323
324.day22 {
325  grid-column: 2/4;
326}
327
328.day23 {
329  grid-column: 4/5;
330}
331
332.day24 {
333  grid-column: 5/6;
334  margin: 3vh 0 0 0;
335}
336
337.day25 {
338  grid-column: 6/7;
339}&lt;!DOCTYPE html&gt;
340&lt;html lang="en"&gt;
341
342&lt;head&gt;
343  &lt;meta charset="UTF-8"&gt;
344  &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
345  &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
346  &lt;title&gt;Document&lt;/title&gt;
347  &lt;link rel="stylesheet" href="style.css"&gt;
348&lt;/head&gt;
349
350&lt;body&gt;
351  &lt;div class="calendar"&gt;
352    &lt;div class="day day1"&gt;1&lt;/div&gt;
353    &lt;div class="day day2"&gt;2&lt;/div&gt;
354    &lt;div class="day day3"&gt;3&lt;/div&gt;
355    &lt;div class="day day4"&gt;4&lt;/div&gt;
356    &lt;div class="day day5"&gt;5&lt;/div&gt;
357    &lt;div class="day day6"&gt;6&lt;/div&gt;
358    &lt;div class="day day7"&gt;7&lt;/div&gt;
359    &lt;div class="day day8"&gt;8&lt;/div&gt;
360    &lt;div class="day day9"&gt;9&lt;/div&gt;
361    &lt;div class="day day10"&gt;10&lt;/div&gt;
362    &lt;div class="day day11"&gt;11&lt;/div&gt;
363    &lt;div class="day day12"&gt;12&lt;/div&gt;
364    &lt;div class="day day13"&gt;13&lt;/div&gt;
365    &lt;div class="day day14"&gt;14&lt;/div&gt;
366    &lt;div class="day day15"&gt;15&lt;/div&gt;
367    &lt;div class="day day16"&gt;16&lt;/div&gt;
368    &lt;div class="day day17"&gt;17&lt;/div&gt;
369    &lt;div class="day day18"&gt;18&lt;/div&gt;
370    &lt;div class="day day19"&gt;19&lt;/div&gt;
371    &lt;div class="day day20"&gt;20&lt;/div&gt;
372    &lt;div class="day day21"&gt;21&lt;/div&gt;
373    &lt;div class="day day22"&gt;22&lt;/div&gt;
374    &lt;div class="day day23"&gt;23&lt;/div&gt;
375    &lt;div class="day day24"&gt;24&lt;/div&gt;
376    &lt;div class="day day25"&gt;25&lt;/div&gt;
377  &lt;/div&gt;
378&lt;/body&gt;
379
380&lt;/html&gt;body {
381  display: grid;
382  align-content: center;
383  justify-content: center;
384  height: 100vh;
385}
386
387.calendar {
388  display: grid;
389  gap: 0.5em;
390  height: 80vh;
391  width: 80vh;
392}
393
394.day {
395  border: 2px solid goldenrod;
396  padding: 0.1em;
397  display: grid;
398  place-items: center;
399  border-radius: 0.3em;
400  transition-duration: 1s;
401}
402
403.day:hover {
404  background-color: goldenrod;
405  color: white;
406  transition-duration: 0.5s;
407}
408
409.day1 {
410  grid-column: 1/2;
411}
412
413.day2 {
414  grid-column: 2/4;
415}
416
417.day3 {
418  grid-column: 4/5;
419}
420
421.day4 {
422  grid-column: 5/6;
423}
424
425.day5 {
426  grid-column: 6/7;
427}
428
429.day6 {
430  grid-column: 1/2;
431}
432
433.day7 {
434  grid-column: 2/3;
435}
436
437.day8 {
438  grid-column: 3/5;
439}
440
441.day9 {
442  grid-column: 5/6;
443}
444
445.day10 {
446  grid-column: 6/7;
447}
448
449.day11 {
450  grid-column: 1/2;
451}
452
453.day12 {
454  grid-column: 2/3;
455}
456
457.day13 {
458  grid-column: 3/4;
459}
460
461.day14 {
462  grid-column: 4/6;
463}
464
465.day15 {
466  grid-column: 6/7;
467}
468
469.day16 {
470  grid-column: 1/2;
471}
472
473.day17 {
474  grid-column: 2/3;
475}
476
477.day18 {
478  grid-column: 3/5;
479}
480
481.day19 {
482  grid-column: 5/6;
483}
484
485.day20 {
486  grid-column: 6/7;
487}
488
489.day21 {
490  grid-column: 1/2;
491}
492
493.day22 {
494  grid-column: 2/4;
495}
496
497.day23 {
498  grid-column: 4/5;
499}
500
501.day24 {
502  grid-column: 5/6;
503}
504
505.day25 {
506  grid-column: 6/7;
507}&lt;!DOCTYPE html&gt;
508&lt;html lang="en"&gt;
509
510&lt;head&gt;
511  &lt;meta charset="UTF-8"&gt;
512  &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
513  &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
514  &lt;title&gt;Document&lt;/title&gt;
515  &lt;link rel="stylesheet" href="style.css"&gt;
516&lt;/head&gt;
517
518&lt;body&gt;
519  &lt;div class="calendar"&gt;
520    &lt;div class="day day1"&gt;1&lt;/div&gt;
521    &lt;div class="day day2"&gt;2&lt;/div&gt;
522    &lt;div class="day day3"&gt;3&lt;/div&gt;
523    &lt;div class="day day4"&gt;4&lt;/div&gt;
524    &lt;div class="day day5"&gt;5&lt;/div&gt;
525    &lt;div class="day day6"&gt;6&lt;/div&gt;
526    &lt;div class="day day7"&gt;7&lt;/div&gt;
527    &lt;div class="day day8"&gt;8&lt;/div&gt;
528    &lt;div class="day day9"&gt;9&lt;/div&gt;
529    &lt;div class="day day10"&gt;10&lt;/div&gt;
530    &lt;div class="day day11"&gt;11&lt;/div&gt;
531    &lt;div class="day day12"&gt;12&lt;/div&gt;
532    &lt;div class="day day13"&gt;13&lt;/div&gt;
533    &lt;div class="day day14"&gt;14&lt;/div&gt;
534    &lt;div class="day day15"&gt;15&lt;/div&gt;
535    &lt;div class="day day16"&gt;16&lt;/div&gt;
536    &lt;div class="day day17"&gt;17&lt;/div&gt;
537    &lt;div class="day day18"&gt;18&lt;/div&gt;
538    &lt;div class="day day19"&gt;19&lt;/div&gt;
539    &lt;div class="day day20"&gt;20&lt;/div&gt;
540    &lt;div class="day day21"&gt;21&lt;/div&gt;
541    &lt;div class="day day22"&gt;22&lt;/div&gt;
542    &lt;div class="day day23"&gt;23&lt;/div&gt;
543    &lt;div class="day day24"&gt;24&lt;/div&gt;
544    &lt;div class="day day25"&gt;25&lt;/div&gt;
545  &lt;/div&gt;
546&lt;/body&gt;
547
548&lt;/html&gt;

Source https://stackoverflow.com/questions/70480850

QUESTION

calendar Ant Design: how to show event only in specific day in month using React JS

Asked 2022-Jan-10 at 10:52

I am looking into ant design calendar documentation.

I want to set events in specific days in current month. I am using this code which provide ant design documentation. But in their code created events were shown in every month.

How can I show for example in April only?

Because in my case I should receive from backend list of events in different years, months and dates and show in calendar.

Here is ant design documentation code

1    function getListData(value) {
2     let listData;
3      switch (value.date()) {
4        case 8:
5          listData = [
6            { type: &quot;warning&quot;, content: &quot;This is warning event.&quot; },
7            { type: &quot;success&quot;, content: &quot;This is usual event.&quot; }
8          ];
9          break;
10        default:
11      }
12      return listData || [];
13    }
14
15    function dateCellRender(value) {
16      const listData = getListData(value);
17      return (
18        &lt;ul className=&quot;events&quot;&gt;
19          {listData.map((item) =&gt; (
20            &lt;li key={item.content}&gt;
21              &lt;Badge status={item.type} text={item.content} /&gt;
22            &lt;/li&gt;
23          ))}
24        &lt;/ul&gt;
25      );
26    }
27
28    ReactDOM.render(
29      &lt;Calendar dateCellRender={dateCellRender} /&gt;,
30      document.getElementById(&quot;container&quot;)
31    );
32
33

And this one is my code which I am receiving from backend.

formattedBooking is my data from backend

1    function getListData(value) {
2     let listData;
3      switch (value.date()) {
4        case 8:
5          listData = [
6            { type: &quot;warning&quot;, content: &quot;This is warning event.&quot; },
7            { type: &quot;success&quot;, content: &quot;This is usual event.&quot; }
8          ];
9          break;
10        default:
11      }
12      return listData || [];
13    }
14
15    function dateCellRender(value) {
16      const listData = getListData(value);
17      return (
18        &lt;ul className=&quot;events&quot;&gt;
19          {listData.map((item) =&gt; (
20            &lt;li key={item.content}&gt;
21              &lt;Badge status={item.type} text={item.content} /&gt;
22            &lt;/li&gt;
23          ))}
24        &lt;/ul&gt;
25      );
26    }
27
28    ReactDOM.render(
29      &lt;Calendar dateCellRender={dateCellRender} /&gt;,
30      document.getElementById(&quot;container&quot;)
31    );
32
33     const getListData = value =&gt; {
34     const listData = [];
35      if (formattedBookings &amp;&amp; formattedBookings[value.date()]) {
36        formattedBookings[value.date()].forEach(booking =&gt; {
37          listData.push({
38            type: 'success',
39            content: `${booking.address}`,
40          });
41        });
42      }
43     return listData;
44    };
45
46
47
48    const dateCellRender = value =&gt; {
49    const listData = getListData(value);
50    return (
51      &lt;ul className='events'&gt;
52        {listData.map((item, index) =&gt; (
53          &lt;li key={`${item.content}-${index}`}&gt;
54            &lt;Badge status={item.type} text={item.content} /&gt;
55          &lt;/li&gt;
56        ))}
57      &lt;/ul&gt;
58     );
59    };
60
61
62
63    return (
64        &lt;Calendar
65          dateCellRender={dateCellRender}
66        /&gt;
67     );
68

Please help me resolve this problem.

ANSWER

Answered 2022-Jan-10 at 10:52

Each value has sent to getListData is a moment object related to a specific day on the calendar view, so you can parse it as the same date format in your backend response, and decide what you want to render in that speceific day. here is an example:

1    function getListData(value) {
2     let listData;
3      switch (value.date()) {
4        case 8:
5          listData = [
6            { type: &quot;warning&quot;, content: &quot;This is warning event.&quot; },
7            { type: &quot;success&quot;, content: &quot;This is usual event.&quot; }
8          ];
9          break;
10        default:
11      }
12      return listData || [];
13    }
14
15    function dateCellRender(value) {
16      const listData = getListData(value);
17      return (
18        &lt;ul className=&quot;events&quot;&gt;
19          {listData.map((item) =&gt; (
20            &lt;li key={item.content}&gt;
21              &lt;Badge status={item.type} text={item.content} /&gt;
22            &lt;/li&gt;
23          ))}
24        &lt;/ul&gt;
25      );
26    }
27
28    ReactDOM.render(
29      &lt;Calendar dateCellRender={dateCellRender} /&gt;,
30      document.getElementById(&quot;container&quot;)
31    );
32
33     const getListData = value =&gt; {
34     const listData = [];
35      if (formattedBookings &amp;&amp; formattedBookings[value.date()]) {
36        formattedBookings[value.date()].forEach(booking =&gt; {
37          listData.push({
38            type: 'success',
39            content: `${booking.address}`,
40          });
41        });
42      }
43     return listData;
44    };
45
46
47
48    const dateCellRender = value =&gt; {
49    const listData = getListData(value);
50    return (
51      &lt;ul className='events'&gt;
52        {listData.map((item, index) =&gt; (
53          &lt;li key={`${item.content}-${index}`}&gt;
54            &lt;Badge status={item.type} text={item.content} /&gt;
55          &lt;/li&gt;
56        ))}
57      &lt;/ul&gt;
58     );
59    };
60
61
62
63    return (
64        &lt;Calendar
65          dateCellRender={dateCellRender}
66        /&gt;
67     );
68function getListData(value) {
69  let listData;
70  let dateValue = value.format(&quot;yyyy/MM/DD&quot;); // you can parse value in every format you want
71  switch (dateValue) {
72    case &quot;2021/12/26&quot;:
73      listData = [
74        { type: &quot;warning&quot;, content: &quot;This is warning event.&quot; },
75        { type: &quot;success&quot;, content: &quot;This is usual event.&quot; }
76      ];
77      break;
78    case &quot;2022/01/12&quot;:
79      listData = [
80        { type: &quot;error&quot;, content: &quot;This is error event 1.&quot; },
81        { type: &quot;error&quot;, content: &quot;This is error event 2.&quot; },
82        { type: &quot;error&quot;, content: &quot;This is error event 3.&quot; }
83      ];
84      break;
85    case &quot;2022/02/08&quot;:
86      listData = [
87        { type: &quot;success&quot;, content: &quot;This is usual event1.&quot; },
88        { type: &quot;success&quot;, content: &quot;This is usual event2.&quot; }
89      ];
90      break;
91    default:
92  }
93  return listData || [];
94}
95

Here is the edited version of your sandbox.

Source https://stackoverflow.com/questions/70650182

QUESTION

Is there a way to disable the month/viewmode button in bootstrap-datetimepicker?

Asked 2021-Nov-28 at 12:06

I've updated bootstrap from version 3 to 4 and noticed the calendar is overlapping when creating it with js instead of cshtml. There's no need to go back more than a few days so I would like to disable the month button that changes the view mode to months or years. Is there a specific CSS property that I need or would I need to edit a code in the library?

viewmode normal

viewmode overlapped

1function AddDateTimeControl(parent, control, rowIndex, controlIndex) {
2    var dateTimeID = &quot;datetimepicker&quot; + controlIndex;
3
4    var tooltipDiv = CreateTooltipDiv();
5    var tooltipSpan = CreateTooltipSpan(control.ToolTip);
6    var label = CreateControlLabel(control);
7    //var icon = CreateIcon('fa-calendar');
8    var icon = CreateIcon(&quot;calendar-alt-regular&quot;);
9
10    tooltipDiv.appendChild(label);
11    tooltipDiv.appendChild(icon);
12    tooltipDiv.appendChild(tooltipSpan);
13
14    var dateDiv = document.createElement(&quot;div&quot;);
15    dateDiv.classList.add('input-group');
16    dateDiv.classList.add('date');
17    dateDiv.classList.add('date-time-control');
18    dateDiv.style.color = &quot;black&quot;;
19    dateDiv.id = dateTimeID;
20
21    var dateTextBox = document.createElement(&quot;input&quot;);
22    dateTextBox.type = &quot;text&quot;;
23    dateTextBox.classList.add(&quot;form-control&quot;);
24    dateTextBox.value = control.RawValues[0];
25
26    MarkElementForSerialization(dateTextBox, rowIndex, control.ID, 0);
27
28    var calControlSpan = document.createElement(&quot;span&quot;);
29    calControlSpan.classList.add('input-group-append'); //input-group-addon?
30    //span -&gt; fa-calendar?
31
32    dateDiv.appendChild(dateTextBox);
33    dateDiv.appendChild(calControlSpan); //input-group-addon
34
35    parent.appendChild(tooltipDiv);
36    parent.appendChild(dateDiv);
37
38    $(dateDiv).datetimepicker();
39    $(dateDiv).data(&quot;DateTimePicker&quot;).sideBySide(true);
40    $(dateDiv).data(&quot;DateTimePicker&quot;).date(new Date(Date.parse(control.RawValues[0])));
41    $(dateDiv).data(&quot;DateTimePicker&quot;).format(&quot;MM/DD/YYYY HH:mm&quot;);
42    $(dateDiv).data(&quot;DateTimePicker&quot;).icons({
43        time: &quot;fa fa-clock-o&quot;,
44        date: &quot;fa fa-calendar&quot;,
45        up: &quot;fa fa-arrow-up&quot;,
46        down: &quot;fa fa-arrow-down&quot;,
47        previous: &quot;fa fa-chevron-left&quot;,
48        next: &quot;fa fa-chevron-right&quot;,
49        today: &quot;fa fa-clock-o&quot;,
50        clear: &quot;fa fa-trash-o&quot;
51    });
52
53    $(dateTextBox).on('click', function() {
54        $(dateDiv).data(&quot;DateTimePicker&quot;).toggle();
55    });
56}
57

ANSWER

Answered 2021-Oct-08 at 16:29

That will depend entirely on which datetimepicker component you are using.

This one lets you set the maximum view:

1function AddDateTimeControl(parent, control, rowIndex, controlIndex) {
2    var dateTimeID = &quot;datetimepicker&quot; + controlIndex;
3
4    var tooltipDiv = CreateTooltipDiv();
5    var tooltipSpan = CreateTooltipSpan(control.ToolTip);
6    var label = CreateControlLabel(control);
7    //var icon = CreateIcon('fa-calendar');
8    var icon = CreateIcon(&quot;calendar-alt-regular&quot;);
9
10    tooltipDiv.appendChild(label);
11    tooltipDiv.appendChild(icon);
12    tooltipDiv.appendChild(tooltipSpan);
13
14    var dateDiv = document.createElement(&quot;div&quot;);
15    dateDiv.classList.add('input-group');
16    dateDiv.classList.add('date');
17    dateDiv.classList.add('date-time-control');
18    dateDiv.style.color = &quot;black&quot;;
19    dateDiv.id = dateTimeID;
20
21    var dateTextBox = document.createElement(&quot;input&quot;);
22    dateTextBox.type = &quot;text&quot;;
23    dateTextBox.classList.add(&quot;form-control&quot;);
24    dateTextBox.value = control.RawValues[0];
25
26    MarkElementForSerialization(dateTextBox, rowIndex, control.ID, 0);
27
28    var calControlSpan = document.createElement(&quot;span&quot;);
29    calControlSpan.classList.add('input-group-append'); //input-group-addon?
30    //span -&gt; fa-calendar?
31
32    dateDiv.appendChild(dateTextBox);
33    dateDiv.appendChild(calControlSpan); //input-group-addon
34
35    parent.appendChild(tooltipDiv);
36    parent.appendChild(dateDiv);
37
38    $(dateDiv).datetimepicker();
39    $(dateDiv).data(&quot;DateTimePicker&quot;).sideBySide(true);
40    $(dateDiv).data(&quot;DateTimePicker&quot;).date(new Date(Date.parse(control.RawValues[0])));
41    $(dateDiv).data(&quot;DateTimePicker&quot;).format(&quot;MM/DD/YYYY HH:mm&quot;);
42    $(dateDiv).data(&quot;DateTimePicker&quot;).icons({
43        time: &quot;fa fa-clock-o&quot;,
44        date: &quot;fa fa-calendar&quot;,
45        up: &quot;fa fa-arrow-up&quot;,
46        down: &quot;fa fa-arrow-down&quot;,
47        previous: &quot;fa fa-chevron-left&quot;,
48        next: &quot;fa fa-chevron-right&quot;,
49        today: &quot;fa fa-clock-o&quot;,
50        clear: &quot;fa fa-trash-o&quot;
51    });
52
53    $(dateTextBox).on('click', function() {
54        $(dateDiv).data(&quot;DateTimePicker&quot;).toggle();
55    });
56}
57$(dateDiv).datetimepicker({ maxView: 1 })
58

However, it was never updated to support Bootstrap 4.

That picker has since been deprecated in favour of eonasdan-bootstrap-datetimepicker, which has an option to set the minimum view, but not the maximum view. You would need to dig in to the code for that version if you wanted to add that option.

There is a newer version of the Eonasdan picker, now called tempus dominus, which is currently in alpha. That version provides options to turn the individual views on or off:

1function AddDateTimeControl(parent, control, rowIndex, controlIndex) {
2    var dateTimeID = &quot;datetimepicker&quot; + controlIndex;
3
4    var tooltipDiv = CreateTooltipDiv();
5    var tooltipSpan = CreateTooltipSpan(control.ToolTip);
6    var label = CreateControlLabel(control);
7    //var icon = CreateIcon('fa-calendar');
8    var icon = CreateIcon(&quot;calendar-alt-regular&quot;);
9
10    tooltipDiv.appendChild(label);
11    tooltipDiv.appendChild(icon);
12    tooltipDiv.appendChild(tooltipSpan);
13
14    var dateDiv = document.createElement(&quot;div&quot;);
15    dateDiv.classList.add('input-group');
16    dateDiv.classList.add('date');
17    dateDiv.classList.add('date-time-control');
18    dateDiv.style.color = &quot;black&quot;;
19    dateDiv.id = dateTimeID;
20
21    var dateTextBox = document.createElement(&quot;input&quot;);
22    dateTextBox.type = &quot;text&quot;;
23    dateTextBox.classList.add(&quot;form-control&quot;);
24    dateTextBox.value = control.RawValues[0];
25
26    MarkElementForSerialization(dateTextBox, rowIndex, control.ID, 0);
27
28    var calControlSpan = document.createElement(&quot;span&quot;);
29    calControlSpan.classList.add('input-group-append'); //input-group-addon?
30    //span -&gt; fa-calendar?
31
32    dateDiv.appendChild(dateTextBox);
33    dateDiv.appendChild(calControlSpan); //input-group-addon
34
35    parent.appendChild(tooltipDiv);
36    parent.appendChild(dateDiv);
37
38    $(dateDiv).datetimepicker();
39    $(dateDiv).data(&quot;DateTimePicker&quot;).sideBySide(true);
40    $(dateDiv).data(&quot;DateTimePicker&quot;).date(new Date(Date.parse(control.RawValues[0])));
41    $(dateDiv).data(&quot;DateTimePicker&quot;).format(&quot;MM/DD/YYYY HH:mm&quot;);
42    $(dateDiv).data(&quot;DateTimePicker&quot;).icons({
43        time: &quot;fa fa-clock-o&quot;,
44        date: &quot;fa fa-calendar&quot;,
45        up: &quot;fa fa-arrow-up&quot;,
46        down: &quot;fa fa-arrow-down&quot;,
47        previous: &quot;fa fa-chevron-left&quot;,
48        next: &quot;fa fa-chevron-right&quot;,
49        today: &quot;fa fa-clock-o&quot;,
50        clear: &quot;fa fa-trash-o&quot;
51    });
52
53    $(dateTextBox).on('click', function() {
54        $(dateDiv).data(&quot;DateTimePicker&quot;).toggle();
55    });
56}
57$(dateDiv).datetimepicker({ maxView: 1 })
58$(dateDiv).tempusDominus({
59   display: {
60     viewMode: 'date',
61     components: {
62       decades: false,
63       year: false,
64       month: false,
65       date: true,
66       hours: true,
67       minutes: true,
68       seconds: false
69     }
70   }
71})
72

Source https://stackoverflow.com/questions/69468631

QUESTION

Ethiopian calendar in Android

Asked 2021-Sep-14 at 08:14

I am developing an Android app for an Ethiopian company and have to deal with dates.

The calendar used in Ethiopia is similar to the Gregorian one but has two main differences: it's set approx. 7 years earlier and has 13 months. At the time I post this question the date is 13-09-2021 in the Gregorian calendar and 03-01-2014 in the Ethiopian one.

My questions are:

  • does Android support the Ethiopian calendar and is it customary for people in Ethiopia to have their devices use it?

  • if so, do I have to get the default formatter (that uses the default calendar: Calendar.getInstance()) in order to format the date properly?

  • instead, if the device uses the Gregorian calendar how does Java support the translation to the Ethiopian date?

What would you suggest in order to simulate the full scenario, with the device set with the proper current Ethiopian date (as if coming from the network provider) and locale?

ANSWER

Answered 2021-Sep-14 at 08:14

While I know nothing about these calendaring systems, perhaps…

ThreeTen-Extra

Add the ThreeTen-Extra library to your project to access the EthiopicChronology class that plugs into the java.time framework bundled with Android.

This chronology defines the rules of the Ethiopic calendar system. This calendar system is primarily used in Ethiopia. Dates are aligned such that 0001-01-01 (Ethiopic) is 0284-08-29 (ISO).

You can also find a CopticChronology class there too.

Source https://stackoverflow.com/questions/69163673

QUESTION

Most reliable hook for setting next renewal payment date after order

Asked 2021-Jul-15 at 18:51

We have a situation in a Woocommerce Subscriptions set up where the default sync options won't work. I've created a manual calendar that my functions.php file references at subscription creation time, but it only ever checks at subscription creation and then the plugin automatically sets the next renewal to be every 4 weeks thereafter.

I need to fire my renewal date checker function after each subscription creation and/or renewal to calculate the next renewal date from my calendar. I know there are at least two hooks I could try, being: wcs_renewal_order_created and woocommerce_subscription_payment_complete, but I don't know enough about when those are triggered to know which is the safest.

About woocommerce_subscription_payment_complete, the WC Subscriptions documentation says:

Triggered when a payment is made on a subscription. This can be payment for the initial order or a renewal order. It is important to note, however, that subscription date changes related to early renewals are processed differently than other renewals, so this action should not be relied upon for capturing the next payment date on a subscription.

I'm not 100% sure what case they refer to in their note, but it was enough to give me pause.

About wcs_renewal_order_created, I am unclear as to when this fires:

These orders are always created through the wcs_create_renewal_order() function, regardless of whether they are created for a scheduled renewal event, manually via the WooCommerce > Edit Subscription administration screen, or via the Subscriptions endpoints for the WooCommerce REST API. Because of this, it’s possible to add, remove or update the value of anything on that renewal order using this filter.

For example, this can be used to add a discount to specific renewal orders, like the 12th order each year. It could also be used to add one-time fee for a certain renewal order, like a special annual extra fee on a monthly subscription.

Would trying to set the next_date key via update_dates() during this hook push the current payment it was about to process or has it already happened and so setting the next date is now safe?

What is the most reliable way to set the next renewal date programmatically immediately after the current period has been processed for a given subscription?

ANSWER

Answered 2021-Jul-15 at 18:51

Disclaimer: I share my reasoning and preliminary information, I did not do any practical check.

Based on the description, both hooks are not related to the events that are required: wcs_renewal_order_created responds to the creation of a subscription order, and woocommerce_subscription_payment_complete responds to payment for such an order. But both of these points are responsible for the "bookkeeping rationale" of the creating or renewing a subscription, not for the creation or renewal itself.

I suggest testing the woocommerce_helper_subscription_activate_success hook, which can be found in the class-wc-helper.php:

1/**
2 * Active a product subscription.
3 */
4private static function _helper_subscription_activate() {
5
6    // ...
7
8    if ( $activated ) {
9        /**
10         * Fires when the Helper activates a product successfully.
11         *
12         * @param int    $product_id Product ID being activated.
13         * @param string $product_key Subscription product key.
14         * @param array  $activation_response The response object from wp_safe_remote_request().
15         */
16        do_action( 'woocommerce_helper_subscription_activate_success', $product_id, $product_key, $activation_response );
17    } else {
18
19    // ...
20

It looks like this hook responds to the moment when the subscription is successfully activated. And there is a possibility that this means not only the moment of the initial activation of the subscription, but also its subsequent renewals.

This can be done with the following code, for example:

1/**
2 * Active a product subscription.
3 */
4private static function _helper_subscription_activate() {
5
6    // ...
7
8    if ( $activated ) {
9        /**
10         * Fires when the Helper activates a product successfully.
11         *
12         * @param int    $product_id Product ID being activated.
13         * @param string $product_key Subscription product key.
14         * @param array  $activation_response The response object from wp_safe_remote_request().
15         */
16        do_action( 'woocommerce_helper_subscription_activate_success', $product_id, $product_key, $activation_response );
17    } else {
18
19    // ...
20function test_woocommerce_helper_subscription_activate_success( $product_id, $product_key, $activation_response ) { 
21   // your code here
22} 
23add_action('woocommerce_helper_subscription_activate_success', 'test_woocommerce_helper_subscription_activate_success', 10, 3);
24

Source https://stackoverflow.com/questions/68194953

QUESTION

iOS 14 widget works locally, but fails via TestFlight

Asked 2021-May-22 at 19:58

I have a SwiftUI app with a widget. When I run the app via Xcode (either straight to my device or on the simulator), the widget works exactly as expected.

However, when I run the app through TestFlight, the widget does appear, but it does not show any data -- it's just the empty placeholder. The widget is supposed to show an image and some text, but it shows neither.

I've seen some posts on Apple Developer forums about similar problems. One accepted answer says the following:

  1. Make sure that you use Xcode 12 beta 4 and iOS 14 beta 4 on your devices. Make sure that you have placeholder(in:) implemented. Make sure that you don't have placeholder(with:) because that's what the previous beta of Xcode was suggesting with autocompletion and without that you won't get your placeholder working. I think this whole problem is caused by the WidgetKit methods getting renamed but that's another story.
  2. As per the release notes, you need to set "Dead Code Stripping" to NO in your extension target's build settings. This is only necessary for the extension's target.
  3. When uploading your archive to the App Store Connect, uncheck "Include bitcode for iOS content".
  4. Delete your old build from a device when installing a new beta.

I've implemented these suggestions, to no avail.

Here's my code for the widget. It first fetches game data via CloudKit, then creates a timeline:

1import WidgetKit
2import SwiftUI
3import CloudKit
4
5struct WidgetCloudKit {
6    static var gameLevel: Int = 0
7    static var gameScore: String = &quot;&quot;
8}
9
10
11struct Provider: TimelineProvider {
12    private var container = CKContainer(identifier: &quot;MyIdentifier&quot;)
13    static var hasFetchedGameStatus: Bool = false
14    
15
16    func placeholder(in context: Context) -&gt; SimpleEntry {
17        return SimpleEntry(date: Date(), gameLevel: 0, gameScore: &quot;0&quot;)
18    }
19
20    
21    func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -&gt; ()) {
22        let entry: SimpleEntry
23
24        if context.isPreview &amp;&amp; !Provider.hasFetchedGameStatus {
25            entry = SimpleEntry(date: Date(), gameLevel: 0, gameScore: &quot;0&quot;)
26        } else {
27            entry = SimpleEntry(date: Date(), gameLevel: WidgetCloudKit.gameLevel, gameScore: WidgetCloudKit.gameScore)
28        }
29        completion(entry)
30    }
31
32
33    func getTimeline(in context: Context, completion: @escaping (Timeline&lt;Entry&gt;) -&gt; ()) {
34            let pred = NSPredicate(value: true)
35            let sort = NSSortDescriptor(key: &quot;creationDate&quot;, ascending: false)
36            let q = CKQuery(recordType: &quot;gameData&quot;, predicate: pred)
37            q.sortDescriptors = [sort]
38
39            let operation = CKQueryOperation(query: q)
40            operation.desiredKeys = [&quot;level&quot;, &quot;score&quot;]
41            operation.resultsLimit = 1
42
43            operation.recordFetchedBlock = { record in
44                DispatchQueue.main.async {
45                    WidgetCloudKit.gameLevel = record.value(forKey: &quot;level&quot;) as? Int ?? 0
46                    WidgetCloudKit.gameScore = String(record.value(forKey: &quot;score&quot;) as? Int ?? 0)
47                    Provider.hasFetchedGameStatus = true
48
49                    var entries: [SimpleEntry] = []
50                    let date = Date()
51
52                    let entry = SimpleEntry(date: date, gameLevel: WidgetCloudKit.gameLevel, gameScore: WidgetCloudKit.gameScore)
53                    entries.append(entry)
54
55                    // Create a date that's 15 minutes in the future.
56                    let nextUpdateDate = Calendar.current.date(byAdding: .minute, value: 15, to: date)!
57                    let timeline = Timeline(entries: entries, policy: .after(nextUpdateDate))
58                    completion(timeline)
59                }
60            }
61
62            operation.queryCompletionBlock = { (cursor, error) in
63                DispatchQueue.main.async {
64                    if let error = error {
65                        print(&quot;queryCompletion error: \(error)&quot;)
66                    } else {
67                        if let cursor = cursor {
68                            print(&quot;cursor: \(cursor)&quot;)
69                        }
70                    }
71                }
72            }
73                    
74            self.container.publicCloudDatabase.add(operation)
75    }
76    
77}
78
79struct SimpleEntry: TimelineEntry {
80    var date: Date
81    var gameLevel: Int
82    var gameScore: String
83}
84
85struct WidgetEntryView : View {
86    var entry: Provider.Entry
87    
88    var body: some View {
89        GeometryReader { geo in
90            VStack {
91                Image(&quot;widgetImage&quot;)
92                    .resizable()
93                    .aspectRatio(contentMode: .fit)
94                    .frame(width: geo.size.width)
95                HStack {
96                    VStack {
97                        Text(&quot;LEVEL&quot;)
98                        Text(entry.gameLevel == 0 ? &quot;-&quot; : &quot;\(entry.gameLevel)&quot;)
99                    }
100                    VStack {
101                        Text(&quot;SCORE&quot;)
102                        Text(entry.gameScore == &quot;0&quot; ? &quot;-&quot; : entry.gameScore)
103                    }
104                }
105            }
106        }
107    }
108}
109
110@main
111struct Widget: SwiftUI.Widget { 
112    let kind: String = &quot;MyWidget&quot;
113    
114    var body: some WidgetConfiguration {
115        StaticConfiguration(kind: kind, provider: Provider()) { entry in
116            WidgetEntryView(entry: entry)
117        }
118        .configurationDisplayName(&quot;Game Status&quot;)
119        .description(&quot;Shows an overview of your game status&quot;)
120        .supportedFamilies([.systemSmall])
121    }
122}
123

Question: Why isn't my widget working when distributed through TestFlight? What are my options, here?

Thank you!

Update: If I use the unredacted() view modifier, the widget shows the image and the "LEVEL" and "SCORE" text, but still does not show any actual data. So, my SwiftUI view now looks like this:

1import WidgetKit
2import SwiftUI
3import CloudKit
4
5struct WidgetCloudKit {
6    static var gameLevel: Int = 0
7    static var gameScore: String = &quot;&quot;
8}
9
10
11struct Provider: TimelineProvider {
12    private var container = CKContainer(identifier: &quot;MyIdentifier&quot;)
13    static var hasFetchedGameStatus: Bool = false
14    
15
16    func placeholder(in context: Context) -&gt; SimpleEntry {
17        return SimpleEntry(date: Date(), gameLevel: 0, gameScore: &quot;0&quot;)
18    }
19
20    
21    func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -&gt; ()) {
22        let entry: SimpleEntry
23
24        if context.isPreview &amp;&amp; !Provider.hasFetchedGameStatus {
25            entry = SimpleEntry(date: Date(), gameLevel: 0, gameScore: &quot;0&quot;)
26        } else {
27            entry = SimpleEntry(date: Date(), gameLevel: WidgetCloudKit.gameLevel, gameScore: WidgetCloudKit.gameScore)
28        }
29        completion(entry)
30    }
31
32
33    func getTimeline(in context: Context, completion: @escaping (Timeline&lt;Entry&gt;) -&gt; ()) {
34            let pred = NSPredicate(value: true)
35            let sort = NSSortDescriptor(key: &quot;creationDate&quot;, ascending: false)
36            let q = CKQuery(recordType: &quot;gameData&quot;, predicate: pred)
37            q.sortDescriptors = [sort]
38
39            let operation = CKQueryOperation(query: q)
40            operation.desiredKeys = [&quot;level&quot;, &quot;score&quot;]
41            operation.resultsLimit = 1
42
43            operation.recordFetchedBlock = { record in
44                DispatchQueue.main.async {
45                    WidgetCloudKit.gameLevel = record.value(forKey: &quot;level&quot;) as? Int ?? 0
46                    WidgetCloudKit.gameScore = String(record.value(forKey: &quot;score&quot;) as? Int ?? 0)
47                    Provider.hasFetchedGameStatus = true
48
49                    var entries: [SimpleEntry] = []
50                    let date = Date()
51
52                    let entry = SimpleEntry(date: date, gameLevel: WidgetCloudKit.gameLevel, gameScore: WidgetCloudKit.gameScore)
53                    entries.append(entry)
54
55                    // Create a date that's 15 minutes in the future.
56                    let nextUpdateDate = Calendar.current.date(byAdding: .minute, value: 15, to: date)!
57                    let timeline = Timeline(entries: entries, policy: .after(nextUpdateDate))
58                    completion(timeline)
59                }
60            }
61
62            operation.queryCompletionBlock = { (cursor, error) in
63                DispatchQueue.main.async {
64                    if let error = error {
65                        print(&quot;queryCompletion error: \(error)&quot;)
66                    } else {
67                        if let cursor = cursor {
68                            print(&quot;cursor: \(cursor)&quot;)
69                        }
70                    }
71                }
72            }
73                    
74            self.container.publicCloudDatabase.add(operation)
75    }
76    
77}
78
79struct SimpleEntry: TimelineEntry {
80    var date: Date
81    var gameLevel: Int
82    var gameScore: String
83}
84
85struct WidgetEntryView : View {
86    var entry: Provider.Entry
87    
88    var body: some View {
89        GeometryReader { geo in
90            VStack {
91                Image(&quot;widgetImage&quot;)
92                    .resizable()
93                    .aspectRatio(contentMode: .fit)
94                    .frame(width: geo.size.width)
95                HStack {
96                    VStack {
97                        Text(&quot;LEVEL&quot;)
98                        Text(entry.gameLevel == 0 ? &quot;-&quot; : &quot;\(entry.gameLevel)&quot;)
99                    }
100                    VStack {
101                        Text(&quot;SCORE&quot;)
102                        Text(entry.gameScore == &quot;0&quot; ? &quot;-&quot; : entry.gameScore)
103                    }
104                }
105            }
106        }
107    }
108}
109
110@main
111struct Widget: SwiftUI.Widget { 
112    let kind: String = &quot;MyWidget&quot;
113    
114    var body: some WidgetConfiguration {
115        StaticConfiguration(kind: kind, provider: Provider()) { entry in
116            WidgetEntryView(entry: entry)
117        }
118        .configurationDisplayName(&quot;Game Status&quot;)
119        .description(&quot;Shows an overview of your game status&quot;)
120        .supportedFamilies([.systemSmall])
121    }
122}
123struct WidgetEntryView : View {
124    var entry: Provider.Entry
125    
126    var body: some View {
127        GeometryReader { geo in
128            VStack {
129                Image(&quot;widgetImage&quot;)
130                    .resizable()
131                    .aspectRatio(contentMode: .fit)
132                    .frame(width: geo.size.width)
133                HStack {
134                    VStack {
135                        Text(&quot;LEVEL&quot;)
136                        Text(entry.gameLevel == 0 ? &quot;-&quot; : &quot;\(entry.gameLevel)&quot;)
137                    }
138                    VStack {
139                        Text(&quot;SCORE&quot;)
140                        Text(entry.gameScore == &quot;0&quot; ? &quot;-&quot; : entry.gameScore)
141                    }
142                }
143            }
144                .unredacted() // &lt;-- I added this
145        }
146    }
147}
148

Update #2: In the article Keeping A Widget Up To Date, there's a section that talks about background network requests:

When your widget extension is active, like when providing a snapshot or timeline, it can initiate background network requests. For example, a game widget that fetches your teammate’s current status, or a news widget that fetches headlines with image thumbnails. Making asynchronous background network requests let you return control to the system quickly, reducing the risk of being terminated for taking too long to respond.

Do I need to set up this (complicated) background request paradigm in order to make CloudKit work for my widget? Am I on the right track?

ANSWER

Answered 2021-May-22 at 18:23

Did you try to deploy the cloudkit container to the production? You can find it on the CloudKit Dashboard.

Source https://stackoverflow.com/questions/67482411

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Calendar

Tutorials and Learning Resources are not available at this moment for Calendar

Share this Page

share link

Get latest updates on Calendar