Change a text and an icon according to the current date of a time zone - flutter

How do i change an icon and a text according to the current date?
For example lets say icon A and a text that says this is the first part of the year appears from January first to June 30th. How do I write my code in flutter so the text changes to this is the second part of the year and then the icon changes to icon B when the current date is July to December. Also, I don't want the code to take the current date from the location of the phone. I want to use the current date of the time zone utc+1.
Also, I got a flutter package for a clock.
Here is the link clock package.
The documentation of the package is not really that detailed. How do I code the clock so it doesn't show the current time of the phone but the current time of a particular time zone I choose. eg utc+1. Thanks a lot for your time.

You can check the month of the current time adjusted per your requirements and display the correct text/icon. Here is an example of how to handle the text. You would follow the same approach for the icon and any other adjustments you'd want to make.
#override
Widget build(BuildContext context) {
final now = DateTime.now().toUtc().add(const Duration(hours: 1));
return Text(
now.month < 7
? 'This is the first half of the year'
: 'This is the second half of the year',
);
}

Related

Syncfusion Calendar Schedule View Set Scroll Position at Start

I am trying to set the initial scroll position as I have a floating search bar that will sit above my calendar.
Here is what it looks like on load as you can see the initial date is hidden:
Here is what I want it to look like on start as you can see the initial date is just below my floating search bar:
Anyone know how I can achieve this? Setting the initial start date 1/2 days behind is not an option as the height will vary based on the number of events in those days.
As per the current implementation of the calendar, there is no support to change the initial scroll position. The calendar will be positioned as the initial date view based on the initial display date value or controller display date value.
Please refer to the following UG link for more information.
https://help.syncfusion.com/flutter/calendar/getting-started#initial-display-date
https://help.syncfusion.com/flutter/calendar/date-navigations#programmatically-change-to-adjacent-dates

Google Sheets: Show values on a tab depending on date

We have a restaurant and want to show the Menu on a screen with google sheets.
I am using 2 tabs in Google sheets, The main (number 1) with the menu showing to the visitors, the second tab (number 2) has all the dates from today until coming 6 weeks like:
Column A
Column B
Column C
Column D
21 June
Appetizer this day
Main dish this day
Desert today
22 June
Appetizer this day
Main dish this day
Desert today
23 June
Appetizer this day
Main dish this day
Desert today
etc. etc.
Now what we want is that the 3 menu items are copied to the main tab on the day of today, so if it is 22 June, the corresponding appetizer, main dish and desert are copied to the main tab.
Is that possible?
This can be achieved with Google Apps Script. You can have a JavaScript code snippet that does this for you.
Open the required spreadsheet. Go to the Tools menu and click Script Editor. This will open up the script editor window with an empty function, code will have to be written inside this function, give it a name, I'm using updateFood():
function updateFood() {
// Fetch all the sheets/tabs of the current spreadhsheet
let sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
// Select the second sheet/tab using [1], first tab will be [0]
// Fetching the second sheet because that is where the data about the upcoming dates are present
let listSheet = sheets[1];
// Get all the data in the sheet
let data = listSheet.getDataRange().getValues();
// Iterate over all data in the sheet
for(i = 0; i < data.length; i++) {
// Get the date of the current row and create a date object
rowDate = new Date(data[i][0]);
// Get today's date
today = new Date();
// Check if the row date is equal to today's date
if(rowDate.setHours(0,0,0,0) == today.setHours(0,0,0,0)) {
// If the code reaches here, this row has the date same as today
// Get the first tab/sheet and then I'm selecting the cells A1, B1 and C1
// Modify the range as per which cells you want the dish names to be in
let range = sheets[0].getRange("A1:C1");
// Set the values of the selected three cells as the value of the second, third and fourth column in the current row of the 2nd tab which are Appetizer, Main dish and Dessert for that date respectively
range.setValues([[data[i][1], data[i][2], data[i][3]]])
}
}
}
And that's all the code you need! Save it and then you can try clicking on run code and then checking the first tab to see the values updated. However, when you click run for the first time, Google will ask you to grant permissions to the script to access your sheet. Click Review Permissions and then click on your account. Then click Advanced and then click:
.
But you will have to run this code every day. This can be achieved using a time-driven trigger.
In the same script editor window, look at the triggers button on the left:
Click on the + Add Trigger on the bottom right of the screen.
And select the values as follows (change the time as required):
That's all you need. Make sure that in the second tab, create dates in the date column with the Excel DATE(YEAR, MONTH, DAY) function rather than manually typing in the dates.

How to change months with Datepicker

Is there any way to change the date (value returned by getDate) pressing the change month arrows without using setDate?
It's not much clear your request..try to specify better; anyway see the documentation about datepicker https://jqueryui.com/datepicker/#dropdown-month-year

Set UIDatePicker text color for dates outside of date range swift

I am playing with a UIDatePicker in my project and I have decided to change the text color to white with
self.datePicker.setValue(UIColor.white, forKey: "textColor")
I also have a minimum date set to today's date. The issue I am having is that the date and time text outside of my minimum date is still grey making it hard to see on my screen. I have been browsing the documentation and am not able to find a list of what key value pairs are available to the class in order to fix this. Thanks.

Displaying day of week

Is there a way to display the day of week (short or long) in the picker itself? I've seen examples of this value getting calculated but I've found nothing that shows a picker that resembles to IOS one where the left most wheel shows the day of the week AND the day of the month...
You can do it with the dateOrder option, where you would need to pass: 'mmD ddy'
It will look something like
$('#demo').mobiscroll().date({
// your inti properties
dateOrder: 'mmD ddy'
});