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
by fullcalendar typescript
14868 MIT
Full-sized drag & drop event calendar
by nhn javascript
9830 MIT
🍞📅A JavaScript calendar that has everything you need.
by huanghaibin-dev java
7808 Apache-2.0
Android上一个优雅、万能自定义UI、仿iOS、支持垂直、水平方向切换、支持周视图、自定义周起始、性能高效的日历控件,支持热插拔实现的UI定制!支持标记、自定义颜色、农历、自定义月视图各种显示模式等。Canvas绘制,速度快、占用内存低,你真的想不到日历居然还可以如此优雅!An elegant, highly customized and high-performance Calendar Widget on Android.
by wix typescript
7635 MIT
React Native Calendar Components 🗓️ 📆
by Pikaday javascript
7485 NOASSERTION
A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS
by patchthecode swift
7165 MIT
The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable
by gelstudios python
6366 MIT
abusing github commit history for the lulz
by jquense javascript
5627 MIT
gcal/outlook like calendar component
by CVCalendar swift
3415 MIT
A custom visual calendar for iOS 8+ written in Swift (>= 4.0).
Trending New libraries in Calendar
by leits swift
2940 Apache-2.0
🇺🇦 Your next meeting always before your eyes in the macOS menu bar
by skerkour rust
1334 NOASSERTION
The simplest way to de-Google your life and business: Inbox, Calendar, Files, Contacts & much more
by fmeringdal rust
447 MIT
A self-hosted calendar and scheduler server.
by lukeed javascript
429 MIT
A tiny (202B) utility to generate calendar views.
by asantibanez php
273 MIT
Laravel Livewire component to show Events in a good looking monthly calendar
by totaldebug typescript
187 MIT
Custom calendar card for Home Assistant with Lovelace
by QuantEcon jupyter notebook
173
Notebooks for https://python.quantecon.org
by aeon-php php
157 MIT
📅 PHP Date & Time library that solves common problems in object oriented, immutable way.
by veccu typescript
120 MIT
:calendar: React Hooks for building extensible calendar user interface (a.k.a Headless Calendar)
Top Authors in Calendar
1
8 Libraries
859
2
6 Libraries
28
3
5 Libraries
1759
4
5 Libraries
10
5
5 Libraries
17504
6
5 Libraries
17
7
5 Libraries
43
8
5 Libraries
1081
9
5 Libraries
27
10
4 Libraries
347
1
8 Libraries
859
2
6 Libraries
28
3
5 Libraries
1759
4
5 Libraries
10
5
5 Libraries
17504
6
5 Libraries
17
7
5 Libraries
43
8
5 Libraries
1081
9
5 Libraries
27
10
4 Libraries
347
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.
- Copy the code using the "Copy" button above, and paste it in a react application in your IDE.
- 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.
- The solution is created in react v18.2.0 and react-calendar v4.0.0
- The solution is tested on chrome browser
Support
- For any support on kandi solution kits, please use the chat
- 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?
- Get the Google API key.
- Restrict the API key.
- Make our calendar public.
- Get the calendar ID, and open google calendar settings.
- Choose the Calendar we want to integrate and copy it from the integrate calendar section.
- 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:41I 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("Select Action");
9 String[] pictureDialogItems = {
10 "Select video from gallery",
11 "Record video from camera" };
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("New File Video:" + Environment.getExternalStorageDirectory());
65 File wallpaperDirectory = new File(Environment.getExternalStorageDirectory() + VIDEO_DIRECTORY);
66 newfile = new File(wallpaperDirectory, Calendar.getInstance().getTimeInMillis() + ".mp4");
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)) > 0) {
82 out.write(buf, 0, len);
83 }
84 in.close();
85 out.close();
86 show_notification("Video file saved successfully.");
87 }else{
88 show_notification("Video saving failed. Source file missing.");
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("path",selectedVideoPath);
106// show_notification("Saving...");
107 saveVideoToInternalStorage(selectedVideoPath);
108 vidView.setVideoURI(contentURI);
109 vidView.requestFocus();
110 vidView.start();
111 videoPath = selectedVideoPath;
112 show_notification("video Gallery - " + 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("video Camera - " + videoPath);
126 }
127 }
128 }
129
ANSWER
Answered 2022-Mar-22 at 18:12I don't know if it will help but maybe you should do startActivityForResult or ActivtyResultLauncher. I would comment that if I had enough reputation.
QUESTION
Problems when writing parquet with timestamps prior to 1900 in AWS Glue 3.0
Asked 2022-Feb-10 at 13:45When 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:45I 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("spark.sql.legacy.parquet.int96RebaseModeInRead", "CORRECTED")
12conf.set("spark.sql.legacy.parquet.int96RebaseModeInWrite", "CORRECTED")
13conf.set("spark.sql.legacy.parquet.datetimeRebaseModeInRead", "CORRECTED")
14conf.set("spark.sql.legacy.parquet.datetimeRebaseModeInWrite", "CORRECTED")
15# Restart spark context
16sc.stop()
17sc = SparkContext.getOrCreate(conf=conf)
18# create glue context with the restarted sc
19glueContext = GlueContext(sc)
20
QUESTION
Discrepancy in Javascript Intl.DateTimeFormat() Outputs for the Islamic (Hijri) Calendar between 'islamic' and 'ar-SA'
Asked 2022-Feb-06 at 13:50The 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)+ " ==> 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:29There are three possible reasons for the "off by one" date problems you're seeing:
- Time zone mismatch between date initialization and date formatting
- Using the wrong variation of the Islamic calendar (JS implementations typically offer 5 different Islamic calendars!)
- 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)+ " ==> 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)+ " ==> 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: "islamic-umalqura"
22// day: "numeric"
23// locale: "ar-SA"
24// month: "numeric"
25// numberingSystem: "arab"
26// timeZone: "America/Los_Angeles"
27// year: "numeric"
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)+ " ==> 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: "islamic-umalqura"
22// day: "numeric"
23// locale: "ar-SA"
24// month: "numeric"
25// numberingSystem: "arab"
26// timeZone: "America/Los_Angeles"
27// year: "numeric"
28// }
29calendars = ["islamic", "islamic-umalqura", "islamic-tbla", "islamic-civil", "islamic-rgsa"];
30options = { timeZone: 'UTC', month: 'long', day: 'numeric', year: 'numeric' };
31date = new Date('2022-03-03');
32calendars.forEach(calendar => {
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.
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:44I 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 = "2.3.1"
13 def nav_version = "2.4.0-alpha04"
14
15 // AAC
16 implementation("androidx.fragment:fragment-ktx:1.3.4")
17
18 // Navigation Component
19 implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
20 implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
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 = "2.3.1"
13 def nav_version = "2.4.0-alpha04"
14
15 // AAC
16 implementation("androidx.fragment:fragment-ktx:1.3.4")
17
18 // Navigation Component
19 implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
20 implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
21
22}
23<navigation xmlns:android="http://schemas.android.com/apk/res/android"
24 xmlns:app="http://schemas.android.com/apk/res-auto"
25 xmlns:tools="http://schemas.android.com/tools"
26 android:id="@+id/nav_graph"
27 app:startDestination="@id/calendar">
28
29 <include app:graph="@navigation/calendar"/>
30 <include app:graph="@navigation/list"/>
31 <include app:graph="@navigation/write_home"/>
32</navigation>
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 = "2.3.1"
13 def nav_version = "2.4.0-alpha04"
14
15 // AAC
16 implementation("androidx.fragment:fragment-ktx:1.3.4")
17
18 // Navigation Component
19 implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
20 implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
21
22}
23<navigation xmlns:android="http://schemas.android.com/apk/res/android"
24 xmlns:app="http://schemas.android.com/apk/res-auto"
25 xmlns:tools="http://schemas.android.com/tools"
26 android:id="@+id/nav_graph"
27 app:startDestination="@id/calendar">
28
29 <include app:graph="@navigation/calendar"/>
30 <include app:graph="@navigation/list"/>
31 <include app:graph="@navigation/write_home"/>
32</navigation>
33<?xml version="1.0" encoding="utf-8"?>
34<navigation xmlns:android="http://schemas.android.com/apk/res/android"
35 xmlns:app="http://schemas.android.com/apk/res-auto"
36 xmlns:tools="http://schemas.android.com/tools"
37 android:id="@+id/write"
38 app:startDestination="@id/home">
39
40 <fragment
41 android:id="@+id/home"
42 android:name="com.example.writeweight.fragment.WriteRoutineHomeFragment"
43 android:label="fragment_write_routine_home"
44 tools:layout="@layout/fragment_write_routine_home" >
45 <action
46 android:id="@+id/action_home_to_dialog"
47 app:destination="@id/dialog" />
48 </fragment>
49 <fragment
50 android:id="@+id/dialog"
51 android:name="com.example.writeweight.fragment.BodyPartDialogFragment"
52 android:label="BodyPartDialogFragment"
53 tools:layout="@layout/fragment_body_part_dialog">
54 <action
55 android:id="@+id/action_dialog_to_write_routine"
56 app:destination="@id/write_routine" />
57 </fragment>
58 <fragment
59 android:id="@+id/write_routine"
60 android:name="com.example.writeweight.fragment.WriteRoutineFragment"
61 android:label="WriteRoutineFragment"
62 tools:layout="@layout/fragment_writing_routine">
63 <argument
64 android:name="title"
65 app:argType="string"
66 app:nullable="true"
67 android:defaultValue="@null"/>
68 <argument
69 android:name="workout"
70 app:argType="string"
71 app:nullable="true"
72 android:defaultValue="@null"/>
73 <action
74 android:id="@+id/action_write_routine_to_workout_tab"
75 app:destination="@id/workout_tab" />
76 </fragment>
77 <fragment
78 android:id="@+id/workout_tab"
79 android:name="com.example.writeweight.fragment.WorkoutListTabFragment"
80 android:label="WorkoutListTabFragment"
81 tools:layout="@layout/fragment_workout_list_tab">
82 <action
83 android:id="@+id/action_workout_tab_to_write_routine"
84 app:destination="@id/write_routine" />
85 </fragment>
86</navigation>
87
ANSWER
Answered 2021-Jul-31 at 20:28in 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 = "2.3.1"
13 def nav_version = "2.4.0-alpha04"
14
15 // AAC
16 implementation("androidx.fragment:fragment-ktx:1.3.4")
17
18 // Navigation Component
19 implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
20 implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
21
22}
23<navigation xmlns:android="http://schemas.android.com/apk/res/android"
24 xmlns:app="http://schemas.android.com/apk/res-auto"
25 xmlns:tools="http://schemas.android.com/tools"
26 android:id="@+id/nav_graph"
27 app:startDestination="@id/calendar">
28
29 <include app:graph="@navigation/calendar"/>
30 <include app:graph="@navigation/list"/>
31 <include app:graph="@navigation/write_home"/>
32</navigation>
33<?xml version="1.0" encoding="utf-8"?>
34<navigation xmlns:android="http://schemas.android.com/apk/res/android"
35 xmlns:app="http://schemas.android.com/apk/res-auto"
36 xmlns:tools="http://schemas.android.com/tools"
37 android:id="@+id/write"
38 app:startDestination="@id/home">
39
40 <fragment
41 android:id="@+id/home"
42 android:name="com.example.writeweight.fragment.WriteRoutineHomeFragment"
43 android:label="fragment_write_routine_home"
44 tools:layout="@layout/fragment_write_routine_home" >
45 <action
46 android:id="@+id/action_home_to_dialog"
47 app:destination="@id/dialog" />
48 </fragment>
49 <fragment
50 android:id="@+id/dialog"
51 android:name="com.example.writeweight.fragment.BodyPartDialogFragment"
52 android:label="BodyPartDialogFragment"
53 tools:layout="@layout/fragment_body_part_dialog">
54 <action
55 android:id="@+id/action_dialog_to_write_routine"
56 app:destination="@id/write_routine" />
57 </fragment>
58 <fragment
59 android:id="@+id/write_routine"
60 android:name="com.example.writeweight.fragment.WriteRoutineFragment"
61 android:label="WriteRoutineFragment"
62 tools:layout="@layout/fragment_writing_routine">
63 <argument
64 android:name="title"
65 app:argType="string"
66 app:nullable="true"
67 android:defaultValue="@null"/>
68 <argument
69 android:name="workout"
70 app:argType="string"
71 app:nullable="true"
72 android:defaultValue="@null"/>
73 <action
74 android:id="@+id/action_write_routine_to_workout_tab"
75 app:destination="@id/workout_tab" />
76 </fragment>
77 <fragment
78 android:id="@+id/workout_tab"
79 android:name="com.example.writeweight.fragment.WorkoutListTabFragment"
80 android:label="WorkoutListTabFragment"
81 tools:layout="@layout/fragment_workout_list_tab">
82 <action
83 android:id="@+id/action_workout_tab_to_write_routine"
84 app:destination="@id/write_routine" />
85 </fragment>
86</navigation>
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 = "2.3.1"
13 def nav_version = "2.4.0-alpha04"
14
15 // AAC
16 implementation("androidx.fragment:fragment-ktx:1.3.4")
17
18 // Navigation Component
19 implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
20 implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
21
22}
23<navigation xmlns:android="http://schemas.android.com/apk/res/android"
24 xmlns:app="http://schemas.android.com/apk/res-auto"
25 xmlns:tools="http://schemas.android.com/tools"
26 android:id="@+id/nav_graph"
27 app:startDestination="@id/calendar">
28
29 <include app:graph="@navigation/calendar"/>
30 <include app:graph="@navigation/list"/>
31 <include app:graph="@navigation/write_home"/>
32</navigation>
33<?xml version="1.0" encoding="utf-8"?>
34<navigation xmlns:android="http://schemas.android.com/apk/res/android"
35 xmlns:app="http://schemas.android.com/apk/res-auto"
36 xmlns:tools="http://schemas.android.com/tools"
37 android:id="@+id/write"
38 app:startDestination="@id/home">
39
40 <fragment
41 android:id="@+id/home"
42 android:name="com.example.writeweight.fragment.WriteRoutineHomeFragment"
43 android:label="fragment_write_routine_home"
44 tools:layout="@layout/fragment_write_routine_home" >
45 <action
46 android:id="@+id/action_home_to_dialog"
47 app:destination="@id/dialog" />
48 </fragment>
49 <fragment
50 android:id="@+id/dialog"
51 android:name="com.example.writeweight.fragment.BodyPartDialogFragment"
52 android:label="BodyPartDialogFragment"
53 tools:layout="@layout/fragment_body_part_dialog">
54 <action
55 android:id="@+id/action_dialog_to_write_routine"
56 app:destination="@id/write_routine" />
57 </fragment>
58 <fragment
59 android:id="@+id/write_routine"
60 android:name="com.example.writeweight.fragment.WriteRoutineFragment"
61 android:label="WriteRoutineFragment"
62 tools:layout="@layout/fragment_writing_routine">
63 <argument
64 android:name="title"
65 app:argType="string"
66 app:nullable="true"
67 android:defaultValue="@null"/>
68 <argument
69 android:name="workout"
70 app:argType="string"
71 app:nullable="true"
72 android:defaultValue="@null"/>
73 <action
74 android:id="@+id/action_write_routine_to_workout_tab"
75 app:destination="@id/workout_tab" />
76 </fragment>
77 <fragment
78 android:id="@+id/workout_tab"
79 android:name="com.example.writeweight.fragment.WorkoutListTabFragment"
80 android:label="WorkoutListTabFragment"
81 tools:layout="@layout/fragment_workout_list_tab">
82 <action
83 android:id="@+id/action_workout_tab_to_write_routine"
84 app:destination="@id/write_routine" />
85 </fragment>
86</navigation>
87plugins {
88 id 'androidx.navigation.safeargs.kotlin'
89}
90plugins {
91 id 'androidx.navigation.safeargs'
92}
93
QUESTION
Flexible layout: Is this one possible?
Asked 2022-Jan-19 at 12:59EDIT 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:
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?
This is all I got until now:
HTML:
1<div class="calendar">
2 <div class="day day1">1</div>
3 <div class="day day2">2</div>
4 <div class="day day3">3</div>
5 <div class="day day4">4</div>
6 <div class="day day5">5</div>
7 <div class="day day6">6</div>
8 <div class="day day7">7</div>
9 <div class="day day8">8</div>
10 <div class="day day9">9</div>
11 <div class="day day10">10</div>
12 <div class="day day11">11</div>
13 <div class="day day12">12</div>
14 <div class="day day13">13</div>
15 <div class="day day14">14</div>
16 <div class="day day15">15</div>
17 <div class="day day16">16</div>
18 <div class="day day17">17</div>
19 <div class="day day18">18</div>
20 <div class="day day19">19</div>
21 <div class="day day20">20</div>
22 <div class="day day21">21</div>
23 <div class="day day22">22</div>
24 <div class="day day23">23</div>
25 <div class="day day24">24</div>
26 <div class="day day25">25</div>
27</div>
28
CSS:
1<div class="calendar">
2 <div class="day day1">1</div>
3 <div class="day day2">2</div>
4 <div class="day day3">3</div>
5 <div class="day day4">4</div>
6 <div class="day day5">5</div>
7 <div class="day day6">6</div>
8 <div class="day day7">7</div>
9 <div class="day day8">8</div>
10 <div class="day day9">9</div>
11 <div class="day day10">10</div>
12 <div class="day day11">11</div>
13 <div class="day day12">12</div>
14 <div class="day day13">13</div>
15 <div class="day day14">14</div>
16 <div class="day day15">15</div>
17 <div class="day day16">16</div>
18 <div class="day day17">17</div>
19 <div class="day day18">18</div>
20 <div class="day day19">19</div>
21 <div class="day day20">20</div>
22 <div class="day day21">21</div>
23 <div class="day day22">22</div>
24 <div class="day day23">23</div>
25 <div class="day day24">24</div>
26 <div class="day day25">25</div>
27</div>
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:08CSS 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<div class="calendar">
2 <div class="day day1">1</div>
3 <div class="day day2">2</div>
4 <div class="day day3">3</div>
5 <div class="day day4">4</div>
6 <div class="day day5">5</div>
7 <div class="day day6">6</div>
8 <div class="day day7">7</div>
9 <div class="day day8">8</div>
10 <div class="day day9">9</div>
11 <div class="day day10">10</div>
12 <div class="day day11">11</div>
13 <div class="day day12">12</div>
14 <div class="day day13">13</div>
15 <div class="day day14">14</div>
16 <div class="day day15">15</div>
17 <div class="day day16">16</div>
18 <div class="day day17">17</div>
19 <div class="day day18">18</div>
20 <div class="day day19">19</div>
21 <div class="day day20">20</div>
22 <div class="day day21">21</div>
23 <div class="day day22">22</div>
24 <div class="day day23">23</div>
25 <div class="day day24">24</div>
26 <div class="day day25">25</div>
27</div>
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
1<div class="calendar">
2 <div class="day day1">1</div>
3 <div class="day day2">2</div>
4 <div class="day day3">3</div>
5 <div class="day day4">4</div>
6 <div class="day day5">5</div>
7 <div class="day day6">6</div>
8 <div class="day day7">7</div>
9 <div class="day day8">8</div>
10 <div class="day day9">9</div>
11 <div class="day day10">10</div>
12 <div class="day day11">11</div>
13 <div class="day day12">12</div>
14 <div class="day day13">13</div>
15 <div class="day day14">14</div>
16 <div class="day day15">15</div>
17 <div class="day day16">16</div>
18 <div class="day day17">17</div>
19 <div class="day day18">18</div>
20 <div class="day day19">19</div>
21 <div class="day day20">20</div>
22 <div class="day day21">21</div>
23 <div class="day day22">22</div>
24 <div class="day day23">23</div>
25 <div class="day day24">24</div>
26 <div class="day day25">25</div>
27</div>
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<div class="calendar">
2 <div class="day day1">1</div>
3 <div class="day day2">2</div>
4 <div class="day day3">3</div>
5 <div class="day day4">4</div>
6 <div class="day day5">5</div>
7 <div class="day day6">6</div>
8 <div class="day day7">7</div>
9 <div class="day day8">8</div>
10 <div class="day day9">9</div>
11 <div class="day day10">10</div>
12 <div class="day day11">11</div>
13 <div class="day day12">12</div>
14 <div class="day day13">13</div>
15 <div class="day day14">14</div>
16 <div class="day day15">15</div>
17 <div class="day day16">16</div>
18 <div class="day day17">17</div>
19 <div class="day day18">18</div>
20 <div class="day day19">19</div>
21 <div class="day day20">20</div>
22 <div class="day day21">21</div>
23 <div class="day day22">22</div>
24 <div class="day day23">23</div>
25 <div class="day day24">24</div>
26 <div class="day day25">25</div>
27</div>
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}<!DOCTYPE html>
340<html lang="en">
341
342<head>
343 <meta charset="UTF-8">
344 <meta http-equiv="X-UA-Compatible" content="IE=edge">
345 <meta name="viewport" content="width=device-width, initial-scale=1.0">
346 <title>Document</title>
347 <link rel="stylesheet" href="style.css">
348</head>
349
350<body>
351 <div class="calendar">
352 <div class="day day1">1</div>
353 <div class="day day2">2</div>
354 <div class="day day3">3</div>
355 <div class="day day4">4</div>
356 <div class="day day5">5</div>
357 <div class="day day6">6</div>
358 <div class="day day7">7</div>
359 <div class="day day8">8</div>
360 <div class="day day9">9</div>
361 <div class="day day10">10</div>
362 <div class="day day11">11</div>
363 <div class="day day12">12</div>
364 <div class="day day13">13</div>
365 <div class="day day14">14</div>
366 <div class="day day15">15</div>
367 <div class="day day16">16</div>
368 <div class="day day17">17</div>
369 <div class="day day18">18</div>
370 <div class="day day19">19</div>
371 <div class="day day20">20</div>
372 <div class="day day21">21</div>
373 <div class="day day22">22</div>
374 <div class="day day23">23</div>
375 <div class="day day24">24</div>
376 <div class="day day25">25</div>
377 </div>
378</body>
379
380</html>
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.
here the previus code1<div class="calendar">
2 <div class="day day1">1</div>
3 <div class="day day2">2</div>
4 <div class="day day3">3</div>
5 <div class="day day4">4</div>
6 <div class="day day5">5</div>
7 <div class="day day6">6</div>
8 <div class="day day7">7</div>
9 <div class="day day8">8</div>
10 <div class="day day9">9</div>
11 <div class="day day10">10</div>
12 <div class="day day11">11</div>
13 <div class="day day12">12</div>
14 <div class="day day13">13</div>
15 <div class="day day14">14</div>
16 <div class="day day15">15</div>
17 <div class="day day16">16</div>
18 <div class="day day17">17</div>
19 <div class="day day18">18</div>
20 <div class="day day19">19</div>
21 <div class="day day20">20</div>
22 <div class="day day21">21</div>
23 <div class="day day22">22</div>
24 <div class="day day23">23</div>
25 <div class="day day24">24</div>
26 <div class="day day25">25</div>
27</div>
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}<!DOCTYPE html>
340<html lang="en">
341
342<head>
343 <meta charset="UTF-8">
344 <meta http-equiv="X-UA-Compatible" content="IE=edge">
345 <meta name="viewport" content="width=device-width, initial-scale=1.0">
346 <title>Document</title>
347 <link rel="stylesheet" href="style.css">
348</head>
349
350<body>
351 <div class="calendar">
352 <div class="day day1">1</div>
353 <div class="day day2">2</div>
354 <div class="day day3">3</div>
355 <div class="day day4">4</div>
356 <div class="day day5">5</div>
357 <div class="day day6">6</div>
358 <div class="day day7">7</div>
359 <div class="day day8">8</div>
360 <div class="day day9">9</div>
361 <div class="day day10">10</div>
362 <div class="day day11">11</div>
363 <div class="day day12">12</div>
364 <div class="day day13">13</div>
365 <div class="day day14">14</div>
366 <div class="day day15">15</div>
367 <div class="day day16">16</div>
368 <div class="day day17">17</div>
369 <div class="day day18">18</div>
370 <div class="day day19">19</div>
371 <div class="day day20">20</div>
372 <div class="day day21">21</div>
373 <div class="day day22">22</div>
374 <div class="day day23">23</div>
375 <div class="day day24">24</div>
376 <div class="day day25">25</div>
377 </div>
378</body>
379
380</html>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<div class="calendar">
2 <div class="day day1">1</div>
3 <div class="day day2">2</div>
4 <div class="day day3">3</div>
5 <div class="day day4">4</div>
6 <div class="day day5">5</div>
7 <div class="day day6">6</div>
8 <div class="day day7">7</div>
9 <div class="day day8">8</div>
10 <div class="day day9">9</div>
11 <div class="day day10">10</div>
12 <div class="day day11">11</div>
13 <div class="day day12">12</div>
14 <div class="day day13">13</div>
15 <div class="day day14">14</div>
16 <div class="day day15">15</div>
17 <div class="day day16">16</div>
18 <div class="day day17">17</div>
19 <div class="day day18">18</div>
20 <div class="day day19">19</div>
21 <div class="day day20">20</div>
22 <div class="day day21">21</div>
23 <div class="day day22">22</div>
24 <div class="day day23">23</div>
25 <div class="day day24">24</div>
26 <div class="day day25">25</div>
27</div>
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}<!DOCTYPE html>
340<html lang="en">
341
342<head>
343 <meta charset="UTF-8">
344 <meta http-equiv="X-UA-Compatible" content="IE=edge">
345 <meta name="viewport" content="width=device-width, initial-scale=1.0">
346 <title>Document</title>
347 <link rel="stylesheet" href="style.css">
348</head>
349
350<body>
351 <div class="calendar">
352 <div class="day day1">1</div>
353 <div class="day day2">2</div>
354 <div class="day day3">3</div>
355 <div class="day day4">4</div>
356 <div class="day day5">5</div>
357 <div class="day day6">6</div>
358 <div class="day day7">7</div>
359 <div class="day day8">8</div>
360 <div class="day day9">9</div>
361 <div class="day day10">10</div>
362 <div class="day day11">11</div>
363 <div class="day day12">12</div>
364 <div class="day day13">13</div>
365 <div class="day day14">14</div>
366 <div class="day day15">15</div>
367 <div class="day day16">16</div>
368 <div class="day day17">17</div>
369 <div class="day day18">18</div>
370 <div class="day day19">19</div>
371 <div class="day day20">20</div>
372 <div class="day day21">21</div>
373 <div class="day day22">22</div>
374 <div class="day day23">23</div>
375 <div class="day day24">24</div>
376 <div class="day day25">25</div>
377 </div>
378</body>
379
380</html>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}<!DOCTYPE html>
508<html lang="en">
509
510<head>
511 <meta charset="UTF-8">
512 <meta http-equiv="X-UA-Compatible" content="IE=edge">
513 <meta name="viewport" content="width=device-width, initial-scale=1.0">
514 <title>Document</title>
515 <link rel="stylesheet" href="style.css">
516</head>
517
518<body>
519 <div class="calendar">
520 <div class="day day1">1</div>
521 <div class="day day2">2</div>
522 <div class="day day3">3</div>
523 <div class="day day4">4</div>
524 <div class="day day5">5</div>
525 <div class="day day6">6</div>
526 <div class="day day7">7</div>
527 <div class="day day8">8</div>
528 <div class="day day9">9</div>
529 <div class="day day10">10</div>
530 <div class="day day11">11</div>
531 <div class="day day12">12</div>
532 <div class="day day13">13</div>
533 <div class="day day14">14</div>
534 <div class="day day15">15</div>
535 <div class="day day16">16</div>
536 <div class="day day17">17</div>
537 <div class="day day18">18</div>
538 <div class="day day19">19</div>
539 <div class="day day20">20</div>
540 <div class="day day21">21</div>
541 <div class="day day22">22</div>
542 <div class="day day23">23</div>
543 <div class="day day24">24</div>
544 <div class="day day25">25</div>
545 </div>
546</body>
547
548</html>
QUESTION
calendar Ant Design: how to show event only in specific day in month using React JS
Asked 2022-Jan-10 at 10:52I 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: "warning", content: "This is warning event." },
7 { type: "success", content: "This is usual event." }
8 ];
9 break;
10 default:
11 }
12 return listData || [];
13 }
14
15 function dateCellRender(value) {
16 const listData = getListData(value);
17 return (
18 <ul className="events">
19 {listData.map((item) => (
20 <li key={item.content}>
21 <Badge status={item.type} text={item.content} />
22 </li>
23 ))}
24 </ul>
25 );
26 }
27
28 ReactDOM.render(
29 <Calendar dateCellRender={dateCellRender} />,
30 document.getElementById("container")
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: "warning", content: "This is warning event." },
7 { type: "success", content: "This is usual event." }
8 ];
9 break;
10 default:
11 }
12 return listData || [];
13 }
14
15 function dateCellRender(value) {
16 const listData = getListData(value);
17 return (
18 <ul className="events">
19 {listData.map((item) => (
20 <li key={item.content}>
21 <Badge status={item.type} text={item.content} />
22 </li>
23 ))}
24 </ul>
25 );
26 }
27
28 ReactDOM.render(
29 <Calendar dateCellRender={dateCellRender} />,
30 document.getElementById("container")
31 );
32
33 const getListData = value => {
34 const listData = [];
35 if (formattedBookings && formattedBookings[value.date()]) {
36 formattedBookings[value.date()].forEach(booking => {
37 listData.push({
38 type: 'success',
39 content: `${booking.address}`,
40 });
41 });
42 }
43 return listData;
44 };
45
46
47
48 const dateCellRender = value => {
49 const listData = getListData(value);
50 return (
51 <ul className='events'>
52 {listData.map((item, index) => (
53 <li key={`${item.content}-${index}`}>
54 <Badge status={item.type} text={item.content} />
55 </li>
56 ))}
57 </ul>
58 );
59 };
60
61
62
63 return (
64 <Calendar
65 dateCellRender={dateCellRender}
66 />
67 );
68
Please help me resolve this problem.
ANSWER
Answered 2022-Jan-10 at 10:52Each 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: "warning", content: "This is warning event." },
7 { type: "success", content: "This is usual event." }
8 ];
9 break;
10 default:
11 }
12 return listData || [];
13 }
14
15 function dateCellRender(value) {
16 const listData = getListData(value);
17 return (
18 <ul className="events">
19 {listData.map((item) => (
20 <li key={item.content}>
21 <Badge status={item.type} text={item.content} />
22 </li>
23 ))}
24 </ul>
25 );
26 }
27
28 ReactDOM.render(
29 <Calendar dateCellRender={dateCellRender} />,
30 document.getElementById("container")
31 );
32
33 const getListData = value => {
34 const listData = [];
35 if (formattedBookings && formattedBookings[value.date()]) {
36 formattedBookings[value.date()].forEach(booking => {
37 listData.push({
38 type: 'success',
39 content: `${booking.address}`,
40 });
41 });
42 }
43 return listData;
44 };
45
46
47
48 const dateCellRender = value => {
49 const listData = getListData(value);
50 return (
51 <ul className='events'>
52 {listData.map((item, index) => (
53 <li key={`${item.content}-${index}`}>
54 <Badge status={item.type} text={item.content} />
55 </li>
56 ))}
57 </ul>
58 );
59 };
60
61
62
63 return (
64 <Calendar
65 dateCellRender={dateCellRender}
66 />
67 );
68function getListData(value) {
69 let listData;
70 let dateValue = value.format("yyyy/MM/DD"); // you can parse value in every format you want
71 switch (dateValue) {
72 case "2021/12/26":
73 listData = [
74 { type: "warning", content: "This is warning event." },
75 { type: "success", content: "This is usual event." }
76 ];
77 break;
78 case "2022/01/12":
79 listData = [
80 { type: "error", content: "This is error event 1." },
81 { type: "error", content: "This is error event 2." },
82 { type: "error", content: "This is error event 3." }
83 ];
84 break;
85 case "2022/02/08":
86 listData = [
87 { type: "success", content: "This is usual event1." },
88 { type: "success", content: "This is usual event2." }
89 ];
90 break;
91 default:
92 }
93 return listData || [];
94}
95
Here is the edited version of your sandbox.
QUESTION
Is there a way to disable the month/viewmode button in bootstrap-datetimepicker?
Asked 2021-Nov-28 at 12:06I'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?
1function AddDateTimeControl(parent, control, rowIndex, controlIndex) {
2 var dateTimeID = "datetimepicker" + 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("calendar-alt-regular");
9
10 tooltipDiv.appendChild(label);
11 tooltipDiv.appendChild(icon);
12 tooltipDiv.appendChild(tooltipSpan);
13
14 var dateDiv = document.createElement("div");
15 dateDiv.classList.add('input-group');
16 dateDiv.classList.add('date');
17 dateDiv.classList.add('date-time-control');
18 dateDiv.style.color = "black";
19 dateDiv.id = dateTimeID;
20
21 var dateTextBox = document.createElement("input");
22 dateTextBox.type = "text";
23 dateTextBox.classList.add("form-control");
24 dateTextBox.value = control.RawValues[0];
25
26 MarkElementForSerialization(dateTextBox, rowIndex, control.ID, 0);
27
28 var calControlSpan = document.createElement("span");
29 calControlSpan.classList.add('input-group-append'); //input-group-addon?
30 //span -> 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("DateTimePicker").sideBySide(true);
40 $(dateDiv).data("DateTimePicker").date(new Date(Date.parse(control.RawValues[0])));
41 $(dateDiv).data("DateTimePicker").format("MM/DD/YYYY HH:mm");
42 $(dateDiv).data("DateTimePicker").icons({
43 time: "fa fa-clock-o",
44 date: "fa fa-calendar",
45 up: "fa fa-arrow-up",
46 down: "fa fa-arrow-down",
47 previous: "fa fa-chevron-left",
48 next: "fa fa-chevron-right",
49 today: "fa fa-clock-o",
50 clear: "fa fa-trash-o"
51 });
52
53 $(dateTextBox).on('click', function() {
54 $(dateDiv).data("DateTimePicker").toggle();
55 });
56}
57
ANSWER
Answered 2021-Oct-08 at 16:29That 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 = "datetimepicker" + 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("calendar-alt-regular");
9
10 tooltipDiv.appendChild(label);
11 tooltipDiv.appendChild(icon);
12 tooltipDiv.appendChild(tooltipSpan);
13
14 var dateDiv = document.createElement("div");
15 dateDiv.classList.add('input-group');
16 dateDiv.classList.add('date');
17 dateDiv.classList.add('date-time-control');
18 dateDiv.style.color = "black";
19 dateDiv.id = dateTimeID;
20
21 var dateTextBox = document.createElement("input");
22 dateTextBox.type = "text";
23 dateTextBox.classList.add("form-control");
24 dateTextBox.value = control.RawValues[0];
25
26 MarkElementForSerialization(dateTextBox, rowIndex, control.ID, 0);
27
28 var calControlSpan = document.createElement("span");
29 calControlSpan.classList.add('input-group-append'); //input-group-addon?
30 //span -> 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("DateTimePicker").sideBySide(true);
40 $(dateDiv).data("DateTimePicker").date(new Date(Date.parse(control.RawValues[0])));
41 $(dateDiv).data("DateTimePicker").format("MM/DD/YYYY HH:mm");
42 $(dateDiv).data("DateTimePicker").icons({
43 time: "fa fa-clock-o",
44 date: "fa fa-calendar",
45 up: "fa fa-arrow-up",
46 down: "fa fa-arrow-down",
47 previous: "fa fa-chevron-left",
48 next: "fa fa-chevron-right",
49 today: "fa fa-clock-o",
50 clear: "fa fa-trash-o"
51 });
52
53 $(dateTextBox).on('click', function() {
54 $(dateDiv).data("DateTimePicker").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 = "datetimepicker" + 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("calendar-alt-regular");
9
10 tooltipDiv.appendChild(label);
11 tooltipDiv.appendChild(icon);
12 tooltipDiv.appendChild(tooltipSpan);
13
14 var dateDiv = document.createElement("div");
15 dateDiv.classList.add('input-group');
16 dateDiv.classList.add('date');
17 dateDiv.classList.add('date-time-control');
18 dateDiv.style.color = "black";
19 dateDiv.id = dateTimeID;
20
21 var dateTextBox = document.createElement("input");
22 dateTextBox.type = "text";
23 dateTextBox.classList.add("form-control");
24 dateTextBox.value = control.RawValues[0];
25
26 MarkElementForSerialization(dateTextBox, rowIndex, control.ID, 0);
27
28 var calControlSpan = document.createElement("span");
29 calControlSpan.classList.add('input-group-append'); //input-group-addon?
30 //span -> 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("DateTimePicker").sideBySide(true);
40 $(dateDiv).data("DateTimePicker").date(new Date(Date.parse(control.RawValues[0])));
41 $(dateDiv).data("DateTimePicker").format("MM/DD/YYYY HH:mm");
42 $(dateDiv).data("DateTimePicker").icons({
43 time: "fa fa-clock-o",
44 date: "fa fa-calendar",
45 up: "fa fa-arrow-up",
46 down: "fa fa-arrow-down",
47 previous: "fa fa-chevron-left",
48 next: "fa fa-chevron-right",
49 today: "fa fa-clock-o",
50 clear: "fa fa-trash-o"
51 });
52
53 $(dateTextBox).on('click', function() {
54 $(dateDiv).data("DateTimePicker").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
QUESTION
Ethiopian calendar in Android
Asked 2021-Sep-14 at 08:14I 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:14While I know nothing about these calendaring systems, perhaps…
ThreeTen-ExtraAdd 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.
QUESTION
Most reliable hook for setting next renewal payment date after order
Asked 2021-Jul-15 at 18:51We 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:51Disclaimer: 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
QUESTION
iOS 14 widget works locally, but fails via TestFlight
Asked 2021-May-22 at 19:58I 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:
- 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.
- 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.
- When uploading your archive to the App Store Connect, uncheck "Include bitcode for iOS content".
- 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 = ""
8}
9
10
11struct Provider: TimelineProvider {
12 private var container = CKContainer(identifier: "MyIdentifier")
13 static var hasFetchedGameStatus: Bool = false
14
15
16 func placeholder(in context: Context) -> SimpleEntry {
17 return SimpleEntry(date: Date(), gameLevel: 0, gameScore: "0")
18 }
19
20
21 func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) {
22 let entry: SimpleEntry
23
24 if context.isPreview && !Provider.hasFetchedGameStatus {
25 entry = SimpleEntry(date: Date(), gameLevel: 0, gameScore: "0")
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<Entry>) -> ()) {
34 let pred = NSPredicate(value: true)
35 let sort = NSSortDescriptor(key: "creationDate", ascending: false)
36 let q = CKQuery(recordType: "gameData", predicate: pred)
37 q.sortDescriptors = [sort]
38
39 let operation = CKQueryOperation(query: q)
40 operation.desiredKeys = ["level", "score"]
41 operation.resultsLimit = 1
42
43 operation.recordFetchedBlock = { record in
44 DispatchQueue.main.async {
45 WidgetCloudKit.gameLevel = record.value(forKey: "level") as? Int ?? 0
46 WidgetCloudKit.gameScore = String(record.value(forKey: "score") 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("queryCompletion error: \(error)")
66 } else {
67 if let cursor = cursor {
68 print("cursor: \(cursor)")
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("widgetImage")
92 .resizable()
93 .aspectRatio(contentMode: .fit)
94 .frame(width: geo.size.width)
95 HStack {
96 VStack {
97 Text("LEVEL")
98 Text(entry.gameLevel == 0 ? "-" : "\(entry.gameLevel)")
99 }
100 VStack {
101 Text("SCORE")
102 Text(entry.gameScore == "0" ? "-" : entry.gameScore)
103 }
104 }
105 }
106 }
107 }
108}
109
110@main
111struct Widget: SwiftUI.Widget {
112 let kind: String = "MyWidget"
113
114 var body: some WidgetConfiguration {
115 StaticConfiguration(kind: kind, provider: Provider()) { entry in
116 WidgetEntryView(entry: entry)
117 }
118 .configurationDisplayName("Game Status")
119 .description("Shows an overview of your game status")
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 = ""
8}
9
10
11struct Provider: TimelineProvider {
12 private var container = CKContainer(identifier: "MyIdentifier")
13 static var hasFetchedGameStatus: Bool = false
14
15
16 func placeholder(in context: Context) -> SimpleEntry {
17 return SimpleEntry(date: Date(), gameLevel: 0, gameScore: "0")
18 }
19
20
21 func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) {
22 let entry: SimpleEntry
23
24 if context.isPreview && !Provider.hasFetchedGameStatus {
25 entry = SimpleEntry(date: Date(), gameLevel: 0, gameScore: "0")
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<Entry>) -> ()) {
34 let pred = NSPredicate(value: true)
35 let sort = NSSortDescriptor(key: "creationDate", ascending: false)
36 let q = CKQuery(recordType: "gameData", predicate: pred)
37 q.sortDescriptors = [sort]
38
39 let operation = CKQueryOperation(query: q)
40 operation.desiredKeys = ["level", "score"]
41 operation.resultsLimit = 1
42
43 operation.recordFetchedBlock = { record in
44 DispatchQueue.main.async {
45 WidgetCloudKit.gameLevel = record.value(forKey: "level") as? Int ?? 0
46 WidgetCloudKit.gameScore = String(record.value(forKey: "score") 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("queryCompletion error: \(error)")
66 } else {
67 if let cursor = cursor {
68 print("cursor: \(cursor)")
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("widgetImage")
92 .resizable()
93 .aspectRatio(contentMode: .fit)
94 .frame(width: geo.size.width)
95 HStack {
96 VStack {
97 Text("LEVEL")
98 Text(entry.gameLevel == 0 ? "-" : "\(entry.gameLevel)")
99 }
100 VStack {
101 Text("SCORE")
102 Text(entry.gameScore == "0" ? "-" : entry.gameScore)
103 }
104 }
105 }
106 }
107 }
108}
109
110@main
111struct Widget: SwiftUI.Widget {
112 let kind: String = "MyWidget"
113
114 var body: some WidgetConfiguration {
115 StaticConfiguration(kind: kind, provider: Provider()) { entry in
116 WidgetEntryView(entry: entry)
117 }
118 .configurationDisplayName("Game Status")
119 .description("Shows an overview of your game status")
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("widgetImage")
130 .resizable()
131 .aspectRatio(contentMode: .fit)
132 .frame(width: geo.size.width)
133 HStack {
134 VStack {
135 Text("LEVEL")
136 Text(entry.gameLevel == 0 ? "-" : "\(entry.gameLevel)")
137 }
138 VStack {
139 Text("SCORE")
140 Text(entry.gameScore == "0" ? "-" : entry.gameScore)
141 }
142 }
143 }
144 .unredacted() // <-- 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:23Did you try to deploy the cloudkit container to the production? You can find it on the CloudKit Dashboard.
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